- Home /
Sprite packing does not reduce draw calls like expected
I've been working on a 2D game and I've noticed a weird behaviour (possibly a bug). This is my scene setup: 1 Camera,1 Archer character,1 Spearman character.
Most of the sprites used by the archer are sprite-packed into the same 'archer' atlas. Most of the spearman sprites are packed into the 'spearman' atlas.
If I enable the archer alone: 5 draw calls
If I enable the spearman alone: 3 draw calls
If I enable them both: 16 draw calls
Shouldn't they be at or below 8 ? It's like one of the characters prevents the other from being batched.
Notes:
No scripts or components are attached to the characters (excluding SpriteRenderer).
All sprites use the same Sprites-Default material
I have tried putting all the sprites on the same layer and order in layer, but the result is the same.
No sprites are flipped, all sprites are scaled to (1,1,1)
The SpritePacking mode in editor is set to: Always enabled
Answer by hexagonius · Sep 17, 2017 at 05:32 AM
This happens when materials are switched for drawing fir due to the ordering. If you enable the frame debugger from the unity windows and step through the calls you will see that it's a back and forth between the two atlases.
You can either pack them both into the same atlas or make sure one is entirely drawn before the other.
Aha, thanks a lot. I didn't even know that 'Frame Debugger Window' existed. I will help me a lot.
Your answer
Follow this Question
Related Questions
HUD with a lot of elements, efficient way? 3 Answers
What's the best way to optimize draw calls with 100,000+ bjects? 1 Answer
How to optimize with a lot of objects 0 Answers
Large Isometric Tilemap Optimisation 0 Answers
Sprites performance issue 0 Answers