Wednesday, March 25, 2020

Order in Hierarchy affect drawcall

The whole draw call thing is a pretty complex topic.
Draw calls are essentially based on the number of materials used. So if you have 20 text objects all using the same Font Asset and Material Preset, you will get 1 draw call. On the other hand, if you are using material instances (which masking requires due to how the Stencil works), you will get more draw calls. Although some of the masking materials can batch, using masking typically results in more draw calls. It is also important to note that Dynamic batching must be enabled for batching between material to occur.
There is also a catch with the Canvas system and Sorting Order / Layer and Canvas batching. If you have several objects in a Canvas which are using the same material but not in a sequential order, batching will be break due to how the objects are sorted / batched. So 3 text objects using the same material would be 1 draw call and 3 images using the same texture 1 draw call. However if the hierarchy is text, image, text, image, text, image. You would get 6 draw calls. This is all controlled by Unity.
See the following post which contains additional information. http://digitalnativestudios.com/forum/index.php…

No comments:

Post a Comment