updated depth constants generation in OIT resolve pass

This commit is contained in:
myT 2024-01-15 17:06:35 +01:00
parent 9e5229a901
commit 708825ea5e
2 changed files with 6 additions and 7 deletions

View file

@ -36,8 +36,8 @@ struct TranspResolveRC
uint16_t centerPixelX;
uint16_t centerPixelY;
uint32_t depthTexture;
float proj22;
float proj32;
float linearDepthA;
float linearDepthB;
float scissorMinX;
float scissorMinY;
float scissorMaxX;
@ -94,8 +94,7 @@ void TranspResolve::Draw(const drawSceneViewCommand_t& cmd)
rc.centerPixelX = glConfig.vidWidth / 2;
rc.centerPixelY = glConfig.vidHeight / 2;
rc.depthTexture = GetTextureIndexSRV(crp.depthTexture);
rc.proj22 = -backEnd.viewParms.projectionMatrix[2 * 4 + 2];
rc.proj32 = backEnd.viewParms.projectionMatrix[3 * 4 + 2];
RB_LinearDepthConstants(&rc.linearDepthA, &rc.linearDepthB);
rc.scissorMinX = backEnd.viewParms.viewportX;
rc.scissorMinY = backEnd.viewParms.viewportY;
rc.scissorMaxX = rc.scissorMinX + backEnd.viewParms.viewportWidth - 1;

View file

@ -35,8 +35,8 @@ cbuffer RootConstants
uint fragmentBuffer;
uint centerPixel; // y: 16 - x: 16
uint depthTexture;
float proj22;
float proj32;
float linearDepthA;
float linearDepthB;
float2 scissorRectMin;
float2 scissorRectMax;
};
@ -94,7 +94,7 @@ float4 DepthFadeFragmentColor(float4 color, OIT_Fragment fragment, float storedD
float4 fadeColorScale = float4(BIT(0), BIT(1), BIT(2), BIT(3));
float4 fadeColorBias = float4(BIT(4), BIT(5), BIT(6), BIT(7));
float zwDepth = storedDepthZW; // stored depth, z/w
float depthS = LinearDepth(zwDepth, proj22, proj32); // stored depth, linear
float depthS = LinearDepth(zwDepth, linearDepthA, linearDepthB); // stored depth, linear
float depthP = fragment.depth - distOffset.y; // fragment depth, linear
float fadeScale = Contrast((depthS - depthP) * distOffset.x, 2.0);
dst = lerp(dst * fadeColorScale + fadeColorBias, dst, fadeScale);