Improve probes relocation algorithm to reduce visual artifacts due to probes flickering
This commit is contained in:
@@ -97,16 +97,10 @@ float LoadDDGIProbeState(DDGIData data, Texture2D<float4> probesState, uint prob
|
||||
// Loads probe world-space position (XYZ) and probe state (W)
|
||||
float4 LoadDDGIProbePositionAndState(DDGIData data, Texture2D<float4> probesState, uint probeIndex, uint3 probeCoords)
|
||||
{
|
||||
float4 result;
|
||||
result.xyz = GetDDGIProbeWorldPosition(data, probeCoords);
|
||||
|
||||
// Probe state contains relocation's offset and the classification's state
|
||||
int2 probeDataCoords = GetDDGIProbeTexelCoords(data, probeIndex);
|
||||
float4 probeState = probesState.Load(int3(probeDataCoords, 0));
|
||||
result.xyz += probeState.xyz;
|
||||
result.w = probeState.w;
|
||||
|
||||
return result;
|
||||
probeState.xyz += GetDDGIProbeWorldPosition(data, probeCoords);
|
||||
return probeState;
|
||||
}
|
||||
|
||||
// Calculates texture UVs for sampling probes atlas texture (irradiance or distance)
|
||||
@@ -193,6 +187,10 @@ float3 SampleDDGIIrradiance(DDGIData data, Texture2D<float4> probesState, Textur
|
||||
probeIrradiance = pow(probeIrradiance, data.IrradianceGamma * 0.5f);
|
||||
#endif
|
||||
|
||||
// Debug probe offset visualization
|
||||
//float4 probeState = probesState.Load(int3(GetDDGIProbeTexelCoords(data, probeIndex), 0));
|
||||
//probeIrradiance = float3(max(frac(probeState.xyz) * 2, 0.1f));
|
||||
|
||||
// Accumulate weighted irradiance
|
||||
irradiance += float4(probeIrradiance * weight, weight);
|
||||
}
|
||||
|
||||
@@ -90,8 +90,13 @@ void CS_Classify(uint3 DispatchThreadId : SV_DispatchThreadID)
|
||||
{
|
||||
if (abs(sdf) < relocateLimit)
|
||||
{
|
||||
// Relocate it
|
||||
probeState.xyz = probeState.xyz + sdfNormal * (sdf + threshold);
|
||||
float3 offsetToAdd = sdfNormal * (sdf + threshold);
|
||||
if (distance(probeState.xyz, offsetToAdd) < relocateLimit)
|
||||
{
|
||||
// Relocate it
|
||||
probeState.xyz = probeState.xyz + offsetToAdd;
|
||||
}
|
||||
// TODO: maybe sample SDF at the relocated location and disable probe if it's still in the geometry?
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -400,6 +405,7 @@ void CS_UpdateBorders(uint3 DispatchThreadId : SV_DispatchThreadID)
|
||||
copyCoordinates = uint2(threadCoordinates.x - 1, probeStart + offset);
|
||||
#endif
|
||||
COPY_PIXEL;
|
||||
|
||||
#undef COPY_PIXEL
|
||||
#undef COPY_PIXEL_DEBUG
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user