Unity version: 2019.3.0f5
URP version: 7.1.8
We noticed a huge FPS drop when using non-animated crossfade on LODGroups.
Here are a few comparision numbers of the same scene and same view, with and without LOD crossfade:
- No fade mode
- Shadows on: 29 SRP batches, 31367 batches, 33ms CPU, 6.5ms GPU, 6.5k verts
- Shadows off: 11 SRP batches, 14599 batches 24.2ms CPU, 6.3ms GPU, 6.5k verts
- Fade mode: crossfade (no animate), settings 0.2
- Shadows on: 4323 SRP batches, 33674 batches, 78ms CPU, 36.3ms GPU, 6.6K verts
- Shadows off: 975 SRP batches, 15119 batches, 30ms CPU, 14ms GPU, 6.5k verts
SRP batches number comes from the frame debugger, the other values come from the stats window.
As you can see, enabling crossfade breaks the SRP batcher.
My best guess is that it’s caused by the LOD_FADE_CROSSFADE keyword, being toggled on / off for each object that should crossfade.
I do however think that the sorter or batcher can do a better job here. Only ± 20% of the rendered objects are affected by the crossfade but the batcher is almost 1000 times less effective. You can also clearly see that the GPU time to render is a lot higher with crossfade on.
Yellow objects have LOD_FADE_CROSSFADE false, red objects have LOD_FADE_CROSSFADE true
Please also note the effect that the SHADOWS have on the batches and performance.
In this scene, there is only a directional light but the impact of the shadows is HUGE.
- How we can reproduce it using the example you attached
- Load LODScene
- Investigate state of the Obj prefab. Check if lodgroup fade mode is “None” or “Crossfade”.
- Press play and take note of the performance in the scene (use frame debugger to get SRP Batch numbers)
- Toggle the value of the lodgroup in the Obj prefab from None to Crossfade or the other way around
- Press play and take not of the performance in the scene (use frame debugger to get SRP Batch numbers)
- Notice SRP batch count and detrimental performance when enabling crossfade.
EXTRA
- Open the UniversalRP-HighQuality asset and toggle “Cast Shadows” on or off.
- Notice HUGE differences in performance
These are the numbers on legacy pipeline, with the same scene:
- No fade mode
- Shadows on: 5958 batches, 53ms CPU, 20ms GPU, 4.1M verts
- Shadows off: 464 batches, 24ms CPU, 4ms GPU, 655K verts
- Fade mode: crossfade (no animate), settings 0.2
- Shadows on: 18947 batches, 68ms CPU, 37ms GPU, 4.2M verts
- Shadows off: 2409 batches, 27ms CPU, 10ms GPU, 667k verts
Issue tracker numbers: 1214825 and 1214826