Why Unity SSGI sampling 0 level mip from Reflection Probe.

Unity SSGI has reflection probe fallback.

But When inetrsection occurs, very large noise occurs.

This is because the code of the SSGI shader is something strange.

float3 R = rayDirection;

float weight = 1.0f;
float intersectionDistance = EvaluateLight_EnvIntersection(posInput.positionWS, normalWS, envLightData, envLightData.influenceShapeType, R, weight);

int index = abs(envLightData.envIndex) - 1;

float2 atlasCoords = GetReflectionAtlasCoordsCube(_CubeScaleOffset[index], R, 0);
float3 probeResult = SAMPLE_TEXTURE2D_ARRAY_LOD(_ReflectionAtlas, s_trilinear_clamp_sampler, atlasCoords, 0, 0).rgb * envLightData.rangeCompressionFactorCompensation;

This is the code for the TraceReflectionProbes section of SSGI.

They do nothing after calculating intersectionDistance.
Perhaps intersectionDistance should have been converted to miplevle and then used as a parameter for sampling.
In fact, it is used that way in other Unity shader codes.
I think there was some confusion when the person in charge left the company.
Anyway, if you want to eliminate SSGI noise as a temporary measure, raise the miplevel.
I am not the person who designed the module, so I cannot restore the exact code, but you can avoid large noise by raising the miplevel to approximately 4.

1 Like

Hey indeed intersectionDistance alters the mip level used in other parts of the code but for different reasons, and mainly because reflection probes are used for specular lighting
Here we use reflection probes for diffuse lighting, which need an important amount of samples to remove the noise. The correct thing to do would be to adapt the mip level based on the roughness but as you’ve mentionned the person in charge left the company and we don’t have the bandwith to look at the issue currently, but you can report a bug, that may help it to get it prioritized