After the Unity6 update I noticed a lot of warnings about “Reduced additional punctual light shadows resolution to make shadow maps fit in the shadow atlas”. I increased the shadowmap resolution from 4k to 8k, but the warnings keep popping on.
I checked the Frame Debugger and indeed the amount of shadowcasters increased from 180 to 460, and then I checked for performance and indeed it is dropped accordingly.
Stats popup in GameView showing, that amount of Shadow casters on the exact same scene with the same camera state raised from 291 to 535.
There are hundreds of sprites on the scene that rendered with the custom shadergraph materials and all of them with individual MaterialPropertyBlock assigned. We not upgraded the Cinemachine yet (VirtualCameras marked as legacy, but it should not affect the performance I assume).
I toggled the Render Graph Compatibility Mode off (as we do not have custom render passes in our project) but seemingly it changed nothing.
Please help me to figure it out, maybe a hint in where to look.
Well that doesn’t look great. My guess here is that the range of your additional lights has changed somehow (I’ll check if we’ve made any changes to this area recently)? That could explain why more things end up having to be rendered in the shadowmap pass, and also why the actual shadowmap looks more “contrasty” in the 17 version.
Contrasty thing is that I manually toggled “Levels” slider in frame debugger, so it’s not the issue. I also think it might be the lights, although their inspector settings are the same and gizmos seems take the same area. Or maybe the render bounds of the sprites were affected
I’m trying to reduce the amount of things on the scene to figure out what’s causing it
Then it’s probably not the lights themselves. You can inspect the different objects being rendered in the draw calls and try and compare with the previous version. Maybe then you can get an idea of which of them have gotten added on.
With just a two sprites, one mesh and one light source I see that Draw Dynamic pass happens 6 times per sprite instead of 1. For some reason the mesh processed in 6 “SRP Batch” calls, but it is the same in older and newer version of URP and the sprites are the issue. Any ideas ?
I tried to create new URP settings + URP data, tried to toggle between Forward and Forward+, tried to toggle different Lighting and Shadows settings in URP asset. Result is the same. Tried also in Unity6.1 beta with no luck. Not sure what else I can do here, I’ll wait for the response from unity team
Hey!
What reason is given in the “Batch Cause” field inside the Frame Debugger?
This is starting to feel like a bug, so could I trick you in to filing a bug about this issue with a small repro like you’re showing there with only two sprites? Does it also repro with only one sprite?
When I test with one sprite, every Shadows.Draw call “Batch cause” is marked with “Unknown reason”. With two sprites the reason for first sprite is “Unknown reason” and for the second “Objects have different MaterialPropertyBlock set”.
When I tried to assemble the bug report I figured out, that this issue is caused specifically by the MaterialPropertyBlocks. I submitted the test project with the material I use in our game and with a script that allows to add/remove property block to see the regression. I hope I didn’t missed anything, it’s my first official bug report.