From c2c92eba824bf52ab1b1ca82f3948b22495436de Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Fri, 19 Dec 2025 00:08:24 +0100 Subject: [PATCH] Adjust 0e76585709946a9184bdba0cceabd501206d1ee4 to not affect depth --- Source/Shaders/GI/DDGI.hlsl | 11 ++++++----- Source/Shaders/GI/DDGI.shader | 9 +++++---- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Source/Shaders/GI/DDGI.hlsl b/Source/Shaders/GI/DDGI.hlsl index c116b597a..9d8f5509c 100644 --- a/Source/Shaders/GI/DDGI.hlsl +++ b/Source/Shaders/GI/DDGI.hlsl @@ -168,7 +168,7 @@ float3 SampleDDGIIrradianceCascade(DDGIData data, Texture2D probes // Loop over the closest probes to accumulate their contributions float4 irradiance = float4(0, 0, 0, 0); - const int3 SearchAxisMasks[3] = { int3(1, 0, 0), int3(0, 1, 0), int3(0, 0, 1) }; + const int3 SearchAxes[3] = { int3(1, 0, 0), int3(0, 1, 0), int3(0, 0, 1) }; for (uint i = 0; i < 8; i++) { uint3 probeCoordsOffset = uint3(i, i >> 1, i >> 2) & 1; @@ -182,10 +182,11 @@ float3 SampleDDGIIrradianceCascade(DDGIData data, Texture2D probes { // Search nearby probes to find any nearby GI sample for (int searchDistance = 1; searchDistance < 3 && probeState == DDGI_PROBE_STATE_INACTIVE; searchDistance++) + { for (uint searchAxis = 0; searchAxis < 3; searchAxis++) { - int searchAxisDir = probeCoordsOffset[searchAxis] ? 1 : -1; - int3 searchCoordsOffset = SearchAxisMasks[searchAxis] * searchAxisDir * searchDistance; + int searchAxisSign = probeCoordsOffset[searchAxis] ? 1 : -1; + int3 searchCoordsOffset = SearchAxes[searchAxis] * (searchAxisSign * searchDistance); uint3 searchCoords = clamp((int3)probeCoords + searchCoordsOffset, int3(0, 0, 0), (int3)probeCoordsEnd); uint searchIndex = GetDDGIScrollingProbeIndex(data, cascadeIndex, searchCoords); float4 searchData = LoadDDGIProbeData(data, probesData, cascadeIndex, searchIndex); @@ -200,6 +201,7 @@ float3 SampleDDGIIrradianceCascade(DDGIData data, Texture2D probes break; } } + } if (probeState == DDGI_PROBE_STATE_INACTIVE) continue; } @@ -232,8 +234,7 @@ float3 SampleDDGIIrradianceCascade(DDGIData data, Texture2D probes // Adjust weight curve to inject a small portion of light const float minWeightThreshold = 0.2f; - if (weight < minWeightThreshold) - weight *= Square(weight) / Square(minWeightThreshold); + if (weight < minWeightThreshold) weight *= (weight * weight) * (1.0f / (minWeightThreshold * minWeightThreshold)); // Calculate trilinear weights based on the distance to each probe to smoothly transition between grid of 8 probes float3 trilinear = lerp(1.0f - biasAlpha, biasAlpha, (float3)probeCoordsOffset); diff --git a/Source/Shaders/GI/DDGI.shader b/Source/Shaders/GI/DDGI.shader index 3dbfd1ed5..bcd1f59fb 100644 --- a/Source/Shaders/GI/DDGI.shader +++ b/Source/Shaders/GI/DDGI.shader @@ -703,16 +703,17 @@ void CS_UpdateProbes(uint3 GroupThreadId : SV_GroupThreadID, uint3 GroupId : SV_ //result.rgb = previous + (irradianceDelta * 0.25f); } result = float4(lerp(result.rgb, previous.rgb, historyWeight), 1.0f); + + // Apply quantization error to reduce yellowish artifacts due to R11G11B10 format + float noise = InterleavedGradientNoise(octahedralCoords, FrameIndexMod8); + result.rgb = QuantizeColor(result.rgb, noise, QuantizationError); #else result = float4(lerp(result.rg, previous.rg, historyWeight), 0.0f, 1.0f); #endif - // Write output irradiance (apply quantization error to reduce yellowish artifacts due to R11G11B10 format) - float noise = InterleavedGradientNoise(octahedralCoords, FrameIndexMod8); - result.rgb = QuantizeColor(result.rgb, noise, QuantizationError); RWOutput[outputCoords] = result; - GroupMemoryBarrierWithGroupSync(); + uint2 baseCoords = GetDDGIProbeTexelCoords(DDGI, CascadeIndex, probeIndex) * (DDGI_PROBE_RESOLUTION + 2); #if DDGI_PROBE_UPDATE_MODE == 0