Search Unity

Question Reflection probe culling (for implementing custom SRP)

Discussion in 'General Graphics' started by burningmime, Dec 8, 2022.

  1. burningmime

    burningmime

    Joined:
    Jan 25, 2014
    Posts:
    845
    Couple issues with reflection probes that have had me stuck for a day or so I can't seem to get Unity to set the reflection probes correctly.

    I am making sure reflection probes are part of the culling data...

    Code (CSharp):
    1.  
    2. if(!camera.TryGetCullingParameters(false, out ScriptableCullingParameters cullParams)) return;
    3. cullParams.cullingOptions |= CullingOptions.NeedsReflectionProbes;
    4. cullParams.reflectionProbeSortingCriteria = ReflectionProbeSortingCriteria.ImportanceThenSize;
    And when creating the renderer list I set up the PerObjectData to have reflection probes...

    Code (CSharp):
    1. RendererListDesc rld = new(SHADER_TAGS, cc.cull, cc.camera);
    2. rld.rendererConfiguration = PerObjectData.ReflectionProbes | PerObjectData.ReflectionProbeData | PerObjectData.Lightmaps | PerObjectData.LightProbe;
    3. rld.sortingCriteria = SortingCriteria.CommonOpaque;
    4. rld.renderQueueRange = RenderQueueRange.opaque;
    The probe itself covers the entire area the meshes are in, and I've verified it baked correctly into the file
    ReflectionProbe-0
    . However, in the frame debugger none of the meshes ever get that probe (only the global one):

    upload_2022-12-8_13-51-0.png

    Just for kicks, I tried doing
    ReflectionProbe.UpdateCachedState()
    each frame, which didn't help.

    I am using Unity 2023.1.a21 (newest alpha version) and Core RP 15.0.2.

    Eventually, I might switch to doing the RP culling on the GPU, at which point this won't matter, but it'd be nice to kinda just get things working in the simple case before I go all fancy.

    ==================================================

    EDIT: If I try to log them out...

    Code (CSharp):
    1. UDebug.Log("Visible reflection probes " + p.cull.visibleReflectionProbes.Length);
    2.             foreach(VisibleReflectionProbe vrp in p.cull.visibleReflectionProbes)
    3.                 UDebug.Log($"VisibleReflectionProbe (center={vrp.center}, bounds={vrp.bounds}, texture={vrp.texture.name})");
    It *does* give me the correct probe (albiet with the wrong center)

    Code (csharp):
    1. VisibleReflectionProbe (center=(0.00, 0.00, 0.00), bounds=Center: (-9.00, 3.50, -5.00), Extents: (10.50, 3.50, 12.00), texture=ReflectionProbe-0)
    So it's there in the cull results but not being set on the draw call.
     
    Last edited: Dec 8, 2022
  2. burningmime

    burningmime

    Joined:
    Jan 25, 2014
    Posts:
    845
    Bump. This (combined with this, which was supposed to be my workaround) are blocking.