From d181f8d72612da86c3f54fe590f275ab85254d71 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Sun, 31 May 2026 12:29:52 +0200 Subject: [PATCH] Fix DDGI sampling when using non-directional lighting (eg. smoke particles or volumetric fog) --- Source/Shaders/GI/DDGI.hlsl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Source/Shaders/GI/DDGI.hlsl b/Source/Shaders/GI/DDGI.hlsl index 92a964d37..7897f9bb5 100644 --- a/Source/Shaders/GI/DDGI.hlsl +++ b/Source/Shaders/GI/DDGI.hlsl @@ -228,8 +228,12 @@ float3 SampleDDGIIrradianceCascade(DDGIData data, Texture2D probes // Smooth backface test // x - weight, y - non-directional weight with a bias +#if LIGHTING_NO_DIRECTIONAL + float2 weights = float2(1, 1); +#else float backfaceWeight = Square(dot(worldPosToProbe, worldNormal) * 0.5f + 0.5f); float2 weights = float2(max(backfaceWeight, 0.1f), backfaceWeight + 0.2f); +#endif // Sample distance texture float2 octahedralCoords = GetOctahedralCoords(-biasedPosToProbe); @@ -303,8 +307,13 @@ float3 SampleDDGIIrradianceCascade(DDGIData data, Texture2D probes float3 GetDDGISurfaceBias(float3 viewDir, float probesSpacing, float3 worldNormal, float bias) { +#if LIGHTING_NO_DIRECTIONAL + return 0; +#else // Bias the world-space position to reduce artifacts return (worldNormal * 0.2f + viewDir * 0.8f) * (0.6f * probesSpacing * bias); + //return worldNormal * (0.2f * probesSpacing * bias); +#endif } // [Inigo Quilez, https://iquilezles.org/articles/distfunctions/]