Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question Why Unity SSGI sampling 0 level mip from Reflection Probe.

Discussion in 'Graphics Experimental Previews' started by kite3h, Apr 19, 2024.

  1. kite3h


    Aug 27, 2012
    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.
    AydinDeveloper likes this.
  2. adrien-de-tocqueville


    Unity Technologies

    Mar 16, 2020
    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