- Home /
2D-Sorting; Does batching affect the order of 2D-Renderers?
Hello Unity-community :)
I was reading the documentation about the 2D sorting process: https://docs.unity3d.com/Manual/2DSorting.html
On that page there are listed several criteria how the 2D sorting process determines the order of 2D-renderers. So far so good :)
One of these criteria is:
Material/Shader
Unity sorts Renderers with the same Material settings together for more efficient rendering performance, such as with dynamic batching
https://docs.unity3d.com/Manual/2DSorting.html#material
After I researched a lot about (static and dynamic) batching I couldn't identify, how exactly batching affects the order of 2D renderers. However, I figured out, that the order of 2D renderers can break batching but that is not relevant for me at the moment.
Therefore, my question: Does batching affect the order of 2D-Renderers at all? And if so, how exactly does it affect the order of two overlapping SpriteRenderer with identical sorting options (same sorting layer and same sorting order)?
Additionally, what would happen, if one or both of these SpriteRenderers can be drawn by using batching?
Thank you very much!
Answer by Cyberfox_ · Oct 31, 2020 at 11:22 AM
Okay after some research, I'm answering my own question :)
Batching is about increasing the performance of what needs to be rendererd. By doing so, batching always guarantees the order of renderers set within the scene. In every render-process, batching is tried to be used, but breaks as soon as necessary conditions (e.g. same material, ...) are no longer met. This means that batching affects the performance of the rendering process, but not the order of the renderers to be displayed.
I couldn’t find out, what exactly happens with overlapping and unsorted renderers. If anyone finds more information on that, please write a comment :)
Your answer
Follow this Question
Related Questions
how to change the render sequence in 2D game ? 2 Answers
Help with batching 0 Answers
tilemap 2d rendering on Y plane 0 Answers
Sprite not visible from behind 0 Answers
Isometric tiles depth 0 Answers