Add improved local-light shadow raytracing by starting ray from light, not surface

This commit is contained in:
Wojtek Figat
2025-11-06 21:01:02 +01:00
parent 3a5bb81d39
commit 59643b2fb9

View File

@@ -165,11 +165,19 @@ float4 PS_Lighting(AtlasVertexOutput input) : SV_Target
BRANCH BRANCH
if (NoL > 0) if (NoL > 0)
{ {
#if RADIAL_LIGHT
// Shot a ray from light to the texel to see if there is any occluder
GlobalSDFTrace trace;
trace.Init(Light.Position, -L, bias, toLightDst);
GlobalSDFHit hit = RayTraceGlobalSDF(GlobalSDF, GlobalSDFTex, GlobalSDFMip, trace, 1.0f);
shadowMask = hit.IsHit() && hit.HitTime < toLightDst - bias * 3 ? LightShadowsStrength : 1;
#else
// Shot a ray from texel into the light to see if there is any occluder // Shot a ray from texel into the light to see if there is any occluder
GlobalSDFTrace trace; GlobalSDFTrace trace;
trace.Init(gBuffer.WorldPos + gBuffer.Normal * shadowBias, L, bias, toLightDst - bias); trace.Init(gBuffer.WorldPos + gBuffer.Normal * shadowBias, L, bias, toLightDst - bias);
GlobalSDFHit hit = RayTraceGlobalSDF(GlobalSDF, GlobalSDFTex, GlobalSDFMip, trace, 2.0f); GlobalSDFHit hit = RayTraceGlobalSDF(GlobalSDF, GlobalSDFTex, GlobalSDFMip, trace, 2.0f);
shadowMask = hit.IsHit() ? LightShadowsStrength : 1; shadowMask = hit.IsHit() ? LightShadowsStrength : 1;
#endif
} }
else else
{ {