vault backup: 2024-09-09 17:44:44

This commit is contained in:
BlueRose 2024-09-09 17:44:44 +08:00
parent 3ebc143f1b
commit 23cd4becc0
2 changed files with 49 additions and 1 deletions

View File

@ -0,0 +1,45 @@
---
title: 深度相关
date: 2024-09-09 16:49:08
excerpt:
tags:
rating: ⭐
---
# 相关代码
位于common.ush
```c++
#define NearDepthValue (HAS_INVERTED_Z_BUFFER ? 1.0f : 0.0f)
#define FarDepthValue (HAS_INVERTED_Z_BUFFER ? 0.0f : 1.0f)
```
可以通过**DeviceZ == FarDepthValue**来判断是否处于最远端。
```c++
float DeviceZ = DepthReadDisabled ? FarDepthValue : LookupDeviceZ(UvBuffer);
#endif
if (DeviceZ == FarDepthValue)
{
// Get the light disk luminance to draw
LuminanceScale = SkyAtmosphere.SkyLuminanceFactor;
#if SOURCE_DISK_ENABLED
if (SourceDiskEnabled > 0)
{
PreExposedL += GetLightDiskLuminance(WorldPos, WorldDir, 0);
#if SECOND_ATMOSPHERE_LIGHT_ENABLED
PreExposedL += GetLightDiskLuminance(WorldPos, WorldDir, 1);
#endif
}
#endif
#if RENDERSKY_ENABLED==0
// We should not render the sky and the current pixels are at far depth, so simply early exit.
// We enable depth bound when supported to not have to even process those pixels.
OutLuminance = PrepareOutput(float3(0.0f, 0.0f, 0.0f), float3(1.0f, 1.0f, 1.0f));
//Now the sky pass can ignore the pixel with depth == far but it will need to alpha clip because not all RHI backend support depthbound tests.
// And the depthtest is already setup to avoid writing all the pixel closer than to the camera than the start distance (very good optimisation).
// Since this shader does not write to depth or stencil it should still benefit from EArlyZ even with the clip (See AMD depth-in-depth documentation)
clip(-1.0f);
return;
#endif
```

View File

@ -134,4 +134,7 @@ FORCEINLINE FSceneTextures& GetActiveSceneTextures() { return ViewFamily.GetScen
| 2000cm | | |
| 5000cm | | |
| 10000cm | | |
# 问题记录
## 处于FarDepthValue的Outline被裁剪的问题
- SkyAtmosphere.usf中会将天空球渲染在深度为FarDepthValue的像素上这样会将一些Outline覆盖掉。
- HeightFogPixelShader.usf中会通过判断**DeviceZ != 0.0** 来调整渲染结果绘制方式PSO.BlendState = TStaticBlendState<CW_RGB, BO_Add, BF_One, BF_SourceAlpha>::GetRHI();