Batching problem : more batches than materials on a fully static model
Hi,
I'm trying to reduce my number of batches (or drawcalls) in my GearVR project. I'm using Unity Free, so no dynamic batching for me.
I have a 3D model I made using Sketch Up, I've tried to keep my number of different materials as low as possible to avoid CPU overhead. The whole model is marked as static (everything static : occluder, occludee, navigation, batching...). I'm not messing with any material of my model through script (so, no, I'm definitely not making clones of the materials at runtime)
At runtime, I do see that static batching helps reducing the number of batches : the "saved by batching" number shows that the batching magic kicks in. Yet I have way too much batches, and I don't understand what goes wrong, but something definitely does : I have a grand total of 50 materials, all using the standard shaders (and changing shaders doesn't change a thing on the batches side), yet depending on where my camera is, disabling my model can reduce the number of batches by roughly 150 (out of 170). How comes?
Note : I only have one camera I only use the standard shader, but they all only use the Aldebo field with the Opaque rendering mode, except 2 materials that use Transparent rendering mode. I use occlusion culling I use light baking (no precomputed realtime GI, baked GI with low parameters for testing purposes)
Thanks in advance for your help.
Answer by DorianF · Nov 16, 2016 at 11:22 AM
Oh, one thought... I just remembered reading that having a mesh with multiple materials was bad, but no one ever explained why.
Exporting from Sketch Up tends to do that sometimes... I'm guessing that could be the reason, I'll try to do some testing and keep this thread updated...
Well, the more test I do, the less I understand batching. I can't make sense out of anything I've tried so far...
I made 2 graphically identical models. I just tried to have some mesh with 2 materials in one, and only one in the other one. I actually failed to do that.
I now have 2 models with 2 identical cubes, with a different texture on each side of the cube. The 2 models are made of 3 meshes, the only difference between them is in their hierarchy.
I made 3 copies of both of these models into an empty Unity scene (a total of 2*2*3 cubes = 12). I've made all of them static and I baked the light.
In my opinion, I should have 7 batches, 1 for each side of one cube, all other faces of all other cubes should be saved by batching since they are copies of the first cube. The remaining one batch would be for the (dynamic) skybox.
I actually get 13 batches. Playing around some more, I've found out that the distance between the camera and the cube could induce additionnal batches. I guess I'm gonna have to search for answers in my quality settings...
Your answer
Follow this Question
Related Questions
Static batching break : objects belong to different static batches 0 Answers
Trouble with Dynamic Batching 0 Answers
LOD batching 0 Answers
Different number of batches in Stats and Frame Debugger counts (222 in stats, 55 in debugger) 1 Answer
Why do I have this jump in draw calls / Batching not working? 0 Answers