How to reproduce:
- Create an empty URP project and open it
- In the Project tab, type “PathTracing” in the Search bar
- In the Project tab, next to the “Search”, click “In Packages” among other scope options
- In the Project tab find the document “Packages/com.unity.render-pipelines.core/Runtime/Lighting/SurfaceCache/PathTracing.hlsl” and open it in the code editor
- Go to 147th line of code and observe
Actual result: In line “PunctualLightSample punctualLightSample = punctualLightSamples[min(punctualLightSampleCount, uniformRand * punctualLightSampleCount)]” the index is clamped to punctualLightSampleCount (out-of-bounds bound)
Expected result: This line “PunctualLightSample punctualLightSample = punctualLightSamples[min(punctualLightSampleCount - 1, uniformRand * punctualLightSampleCount)]” should have “punctualLightSampleCount - 1” (the last valid index)
Reproducible with: 6000.5.0a4, 6000.5.5f1, 6000.6.0b5, 6000.7.0a3
Could not test with: 6000.0.79f1, 6000.3.20f1 (the affected code doesn't exist)
Reproducible on: Windows 11 Enterprise (25H2)
Not reproducible on: No other environments tested
Notes:
- The SurfaceCache Realtime GI feature (PathTracing.hlsl) was only introduced in 6000.5.0a4
- In “com.unity.render-pipelines.core\Runtime\Lighting\SurfaceCache\PunctualLightSampling.hlsl”, punctualLightIndex is as it should be: "punctualLightIndex = min(rng.GetSample(0).x * _PunctualLightCount, _PunctualLightCount - 1);"