- Home /
How do you get proper static batching?
In this article: https://cgcookie.com/articles/maximizing-your-unity-games-performance, the author says the following two things under the "dynamic batching" section:
"GameObjects are not batched if they contain mirroring on the transform (for example GameObject A with +1 scale and GameObject B with –1 scale cannot be batched together). Using different Material instances causes GameObjects not to batch together, even if they are essentially the same. The exception is shadow caster rendering."
My question is; are these two things true with static batching? With static batching, do you not get batching between two of the same gameobjects if they have different scales? How about rotation? Secondly, what about material instances? What do they even mean by "material instances", for that matter? How could you have two objects with the same material and have it not be two material instances? I only ask, because this article and the Unity documentation I've found doesn't explicitly say certain things and I feel like it could be worded better.
Answer by unity_ek98vnTRplGj8Q · Feb 11, 2021 at 05:30 PM
From my experience with batching:
The rotation / scale of batched objects does not matter, as long as the scale is not negative in any axis
When they talk about material instances, they means as long as the reference to the material in the renderer script between two objects points to the exact same material in your project directory it will batch. But, for example, if you have a material in your project directory and you create a copy of it, then put the original on 1 object and the copy on a second object it will NOT batch, even though the materials are essentially the same, they are not the same instance of the material and will not batch.
This confusion with material instances can sometimes arise when using sets of assets built using outside software. I had once bought a bunch of building prefabs for my project, and even though some of these buildings were built using the same material, when they were imported to Unity each prefab contained its own instance of the material. In order to get these objects to batch, I had to write a script that went through each building and pointed common material references to the same material instance.
Your answer
![](https://koobas.hobune.stream/wayback/20220613025014im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How performance heavy is dynamic batching? 0 Answers
Getting statistics info in a script? 0 Answers
Draw calls on instantiated prefabs? help 0 Answers
Batching objects problem 1 Answer
Dynamic batching not working? 0 Answers