Sprites from same atlas - different draw calls

Hi everyone. I’m rendering a scene in a 2d game and using Frame Debugger (btw thanks a lot whoever did it) to understand the amount of draw calls etc.
On the 2 screenshots below you may see 2 subsequent draw calls, 1st draws a golden chest and the 2nd draws 2 characters (a princess & a mage). The thing is the characters AND the chest are in the same atlas:

On the next screenshot you may see the inspector view of all 3 objects:


So the question is, why are they being drawn in separate draw calls? Same atlas, similar sprite renderer settings, similar transforms etc. What else should I check to make them appear in a single draw call?

Thanks in advance!

EDIT: Long story short the problem was with the SpriteSkin component. If a game object has it - it doesn’t render in the same draw call with objects that don’t have it.

Anyone? :slight_smile:

Oh Unity gurus, I summon you to share a piece of knowledge about batching, draw calls and other types of dark magic!

Have you tried if it makes a difference if all sprites use the same “Order in Layer” value? Google found several hits that discuss using different values on that setting can break batching.

Hey thank you for the reply! As you may see from screenshot #2 the chest and the mage have equal Order in Layer yet they render in separate draw calls. The mage and the princess have different order but render in same draw call. Alas.
Just now I tried to put them all on the same layer out of curiosity and it had no effect :slight_smile: The chest renders separately.

other things that could separate batches - different material(though you seem to be using the same), different lighting (though sprites default is not affected by lighting)

perhaps show a screenshot of your atlas preview, lets confirm that they really are in the same atlas

Thank you for the reply! Everything you’ve said is correct, here’s the atlas:
6032720--651248--drawcall4.png

The Frame Debugger says it’s caused because of different MaterialPropertyBlocks. Do you use them in code or use other packages that might use them?
If you remove all Components (before enter playmode) but the SpriteRenderer from all objects, do they still not batch?

1 Like

MaterialPropertyBlocks, I don’t even know what’s this :slight_smile: Besides it says so for the FIRST draw call, not for the SECOND one. The first one can’t be batched with it’s previous one, because on the previous one I’m drawing walls etc which are in different atlas. That’s normal. The thing is Frame Debugger doesn’t even explain why can’t it batch the second draw call with the first one. Or I just can’t understand it :slight_smile:

@Peter77 , @raarc Problem kind of solved! I disabled SpriteSkin component (by Peter77’s advice) for the mage and the princess and they started batching with the chest! Well, I’m not sure if it’s a bug or not, but I can’t get rid of SpriteSkin in my game so I have to live with this extra draw call. Thank you guys for participating!

1 Like