Skip to content

Commit 289b1ac

Browse files
Enable OIT with reverse depth
1 parent 469dd31 commit 289b1ac

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

Shaders/PBR/private/RenderPBR.psh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,12 @@ PSOutput main(in VSOutput VSOut,
542542
#if NUM_OIT_LAYERS > 0
543543
if (BaseColor.a > OIT_OPACITY_THRESHOLD)
544544
{
545-
float T = GetOITTransmittance(VSOut.ClipPos.z, uint2(VSOut.ClipPos.xy));
545+
float D = VSOut.ClipPos.z;
546+
if (g_Frame.Camera.fNearPlaneDepth > g_Frame.Camera.fFarPlaneDepth)
547+
{
548+
D = 1.0 - D;
549+
}
550+
float T = GetOITTransmittance(D, uint2(VSOut.ClipPos.xy));
546551
OutColor.rgb *= T;
547552
}
548553
#endif

Shaders/PBR/private/UpdateOITLayers.psh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ PSOutput main(in VSOutput VSOut,
5252
in bool IsFrontFace : SV_IsFrontFace)
5353
{
5454
float D = VSOut.ClipPos.z;
55+
if (g_Frame.Camera.fNearPlaneDepth > g_Frame.Camera.fFarPlaneDepth)
56+
{
57+
D = 1.0 - D;
58+
}
5559
#if USE_MANUAL_DEPTH_TEST
5660
if (D >= g_DepthBuffer.Load(int3(VSOut.ClipPos.xy, 0)))
5761
{

0 commit comments

Comments
 (0)