# Submeshes increase draw calls... any way around this?

I’m doing a test, learning about how batching works. I have a simple script where, every time I press Space Bar, a cube is created. The cube is assigned a random material from a group of 5. Due to dynamic batching, even if I have 100 cubes on screen, my total draw calls never goes above 5. So far, so good!

However, if I break the cube into 6 submeshes (one for each face), assign each face with a random material of the 5, and start spawning cubes, I hit a maximum of 30 draw calls. If the cube is only divided into 2 submeshes, my maximum number of draw calls will be 10. The equation is pretty obvious:

``````(# of draw calls) = (# of total materials showing) * (# of submeshes on each cube)
``````

So, is it possible for the number of draw calls to get back down to 5, even with the cubes divided into submeshes? There’s still only 5 materials showing on screen, and its obvious that some kind of batching is happening.

UPDATE: After more research, I’ve gotten no closer to solving this, so I’m just assuming that it’s a limitation I have to work with. It’s not a huge deal for me, but I’m leaving the question unanswered for now in case someone happens upon this in the future and can shed light on it.

sub meshes are different than actual meshes

batching works on the mesh level so if you have submeshes the object is treated as a completely different entity when rendering.

hmmm i should explain that differently

when it goes to render an object it looks at the material assigned to it, objects with the same material get batched. But its not objects in the sense of a GO its the mesh object that it is looking at so if you have sub meshes with different materials then the mesh itself is a different ‘object’ in the renderer. so having submeshes with different materials is not good for batching.

now what im curious about is there are two objects with the same difuse material but one has a normal. will they get batched and the normal map gets rendered later or does the object become unique.

unrelated (this is more rumor) but triangle count might affect batching as well i believe 300 triangles is the rough limit for an object to batch

Submeshes in the same mesh share one VBO and one IBO, but still invoke drawcall indivitually. The reason submeshes are better than separate gameobjects is that they counld be batched if sharing same material. It do call multiple drawcalls (glDrawElements in GL) compare to single big mesh. But the cost of a drawcall is kind small, we could ignore it. “Batching” reduces vertex data binding and model matrix uploading at CPU side, but not reduce number of drawcall( except dynamic batching).