Reverse depth is now working in the shadow pass

This commit is contained in:
2025-09-27 21:50:01 +02:00
parent ed69a21b80
commit a2f1e0bd8c
12 changed files with 127 additions and 134 deletions
+3 -3
View File
@@ -27,7 +27,7 @@ ParameterBlock<LightCullingData> pLightCullingData;
static const float4x4 biasMat = float4x4(
0.5, 0.0, 0.0, 0.5,
0.0, -0.5, 0.0, 0.5,
0.0, 0.5, 0.0, 0.5,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0);
@@ -46,7 +46,7 @@ float4 fragmentMain(in FragmentParameter params) : SV_Target
{
uint cascadeIndex = 0;
for (uint c = 0; c < NUM_CASCADES - 1; ++c) {
if (params.position_VS.z > pShadowMapping.cascadeSplits[c]) {
if (params.position_VS.z < pShadowMapping.cascadeSplits[c]) {
cascadeIndex = c + 1;
}
}
@@ -68,7 +68,7 @@ float4 fragmentMain(in FragmentParameter params) : SV_Target
if (shadowCoord.z > 0.0 && shadowCoord.z < 1.0)
{
float dist = pShadowMapping.shadowMaps[cascadeIndex].Sample(pShadowMapping.shadowSampler, float3(shadowCoord.xy + float2(dx * x, dy * y), i)).r;
if (shadowCoord.w > 0 && dist > shadowCoord.z)
if (shadowCoord.w > 0 && dist < shadowCoord.z)
{
shadow = 0;
}