We're getting to the optimization stages of our project and are having some troubles controlling our batch count.
I've combed through various posts on the matter, many of which are rather old by the standards of technological progression. As an artist, there are some things I would love to have clarified so I can make better decisions when it comes to generating/optimizing art assets. This thread might be a bit long so I'll try to segment it as best I can.
discusses draw calls and how/when they are batched. Different models with the same materials and textures can be batched, sure; but specifically, can two different models with a different amount
of material IDs be batched? Since meshes get chopped up by material ID as part of the render state, do the IDs that are present on both models get batched together or does nothing batch since they don't share the exact
same material IDs?
I read the Render Hell
article and it was difficult to grasp (again, I'm a paint-slinging artist person, not a graphics programmer). It explains draw calls and render states, and how render states are the more "expensive" part of processing data. From what I understand, every time a new batch has to render, the render state changes, which is slow. So, fewer batches means fewer render state changes which results in faster processing of data.
I've also noticed that Unity's "stats" panel in the game window no longer displays draw calls, but instead counts batches. Is this because batches are the biggest problem compared to draw calls?
I'm sure there's a balance somewhere, but it would be nice to know some sort of rough estimate of how any batches is "equal to" a draw call in regards to performance.
For instance, which is most efficient:
- 500 draw calls and 500 batches
- 200 draw calls and 800 batches
- 800 draw calls and 200 batches
Obviously less of both is better, however if it's possible to increase one in order to reduce the other and subsequently gain performance... Yeah, I want to do that.
This is sort of a continuation of Question 2. The project I am on uses mostly tiling textures, so our structures have upwards of 10, even 25 material IDs depending on their size. Many of the structures share the same material IDs but there are a LOT of polygons so I'm assuming many of these identical materials have to get split into different rendering chunks which, if I understood Render Hell correctly, increases the batch count.
Let's say I grouped all our structures into smaller groups. If I gave each smaller group their own "set" of materials that wouldn't be used with other groups, that would probably increase the draw call total quite a bit, however the batch count should go down substantially since the GPU wouldn't have to split as many polygons into chunks for rendering the same one material.
Here are some arbitrary numbers to help visualize the two scenarios:
- 10 structures with a total of 25 materials shared between them all. They're pretty high poly so batching is likely to happen on most materials.
- 10 structures with 5 materials assigned to each structure but not used on any of the other 9 structures. So, 50 materials total but they are assigned to fewer total polygons which means fewer split chunks and fewer batches?
I often hear that engines don't like "long, thin triangles" and it has to do with how the pixels are cut off in areas where they don't fit in (overdraw, or something like that I think). What exactly determines whether a triangle is too long and thin? Is it based on how much screen space that object takes up, or how acute the edges are? What if there are two identical models with long, thin triangles but one is scaled much larger than the other? Are they still both causing problems?
Thanks in advance for anyone who took the time to read and answer part/all of my questions.
TL;DR Optimization is a huge pain and I'd like to know if batches are worse for performance than draw calls. Also someone should really make an Earthquake-style thread with practical applications of the concepts of draw calls and batching.