I have a game object with a sprite renderer and a sprite mask the sprite renderer is creating adding 1 draw call while the sprite mask is adding 2 draw calls, for a total of 3 draw calls When I spawn 100 game objects its now 300 draw calls These objects all share the same sprite and sprite mask, and I have tried adding them to an atlas to no avail. They all share the same material too. I'm using the URP 2d renderer pipeline with a lit shader, and all sprites are lit by the same global light. this is annoying because I am managing to batch the tiles in my tilemap and Im saving a lot by batching those, I wanted to save while using sprite renderers aswell. Am I doing something wrong or is it normal that 1 sprite renderer always generates 1 draw call that cant be saved by batching?
So i think I homed in on the problem, sorting groups seem to be breaking the batching? Is it possible to batch with sorting groups?
With SpriteRenderers I seem to recall having diffrent .color properties will trigger fresh batch calls. Annoyingly sometimes getting the drawcalls down requires reorganizing your GameObject hierarchy so that Unity is able to collapse things that you think can be collapsed. Now this here is for UI, but perhaps there's some meaty info in here regarding your issue? https://learn.unity.com/tutorial/optimizing-unity-ui
Could you share some details of your setup with the SpriteRenderers, SortingGroup and SpriteMask, eg. how are they set up in the Hierarchy? Also, would it be possible to share the details of how batching is (not) done by using the FrameDebugger? The FrameDebugger will show a reason why the SpriteRenderers are not batching. Generally, each SpriteMask does not batch with each other and that can cause the SpriteRenderers not to batch if each SpriteRenderer uses its own SpriteMask.
yes that is what is causing it I have for hierarchy Game Object -Sorting group1 --Sprite mask1 ---Masked sprite1 -Sorting group2 --Sprite mask2 ---Masked sprite2 this object produces 6 draw calls, after i clone it 12 etc etc if i take the stuff out of the sorting groups and remove the masks its only 2 draw calls no matter how many clones