Number of active lights in _LightDatas buffer

Hi!
I want to evaluate some lights from _LightDatas buffer. I see that this buffer isn’t cleared every frame, so if a light is disabled (maybe even removed ?) its data is still present in the buffer. Knowing the number of active lights in every frame would greatly help me in this case, but I can’t find it anywhere. Is is available?
@antoinel_unity, may be you can help with it? :slight_smile:

Hey,

This is the buffer that we use for all the lights in HDRP when cluster/tile is not used so it is updated with only the visible lights to the current camera, the rest of the buffer can contain garbage.

You can use the functions and variables to fetch light indices before accessing the array like so: Graphics/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/HDShadowLoop.hlsl at master · Unity-Technologies/Graphics · GitHub
take the path where LIGHTLOOP_DISABLE_TILE_AND_CLUSTER is active so that it’s easier to follow.

1 Like