- Home /
Dynamic Batching not working even adhering to all rules
Trying to get dynamic batching to work without having to go under 300 verts:
Using Unity 5.3.1f
Already checked these rules:
They share the same material
Materials not instanced
Unity shows the vertex count being under 900
Using most simple shader (only a color is output)
Forward render mode
No Transparency or alpha
No light or shadows and switched off all the settings for receiving shadows etc.
Scaling is uniform (1,1,1)
No layering of objects in the view
Not instancing object from code
No lightmaps
Both in scene when rendered with material applied (simple shader), and viewing imported mesh in the project view we see the object having:
789 verts and 472tris
The mesh in question has vertex color and a uv applied. Testing has proven that removing either of these reduces the number of verts counted by Unity (to 238 verts) , we assume these are not counted additionally to the 789 verts as they are already included.
Our goal: We would like to be able to batch moving objects with a low polycount with vertex color and a uv applied, dynamic batching is behaving very unpredictable up and till now. If anyone has an idea why this would not work we would be very grateful...
Answer by BenSan · Feb 18, 2016 at 09:07 AM
The Documentation refered to in the question seems to be wonky:
batching is applied only to meshes containing less than 900 vertex attributes in total.
even though Unity displays the amount of vertex attributes directly in the editor we never got it to batch with anything over 300 vertex attributes. This line does hint that the actual limit might change: "Please note: attribute count limit might be changed in future"
Either Unity does not account for certain attributes when counting the vertex attributes inside the editor or (as of the time of speaking) the documentation is wrong.
Solution:
Testing showed us that dynamic batching has too much overhead for what we need. We now batch all meshes manually and update the combined mesh when something changes which is not all to often.
For this we use the combineMeshes method.
Answer by nkmxzhang · Feb 18, 2016 at 11:40 AM
Batching dynamic objects has certain overhead per vertex, so batching is applied only to meshes containing less than 900 vertex attributes in total.
If your shader is using Vertex Position, Normal and single UV, then you can batch up to 300 verts; whereas if your shader is using Vertex Position, Normal, UV0, UV1 and Tangent, then only 180 verts.
dynamic batching vertex limit count = 900 / Shader vertex attribute count
so, if you want to use dynamic batching, please check the shader used.
I don't entirely understand your calculation on how the limit is defined.
If the amount of vertex-attributes is not allowed to go above 900, then we have (apparently) made sure that it doesn't. I wasn't sure if we were missing something. We checked inside the Editor and it displays the difference when adding and removing vertex colors for instance. So if the editor displays less than 900 we should be okay.
We used the most simple shader possible and it did not batch. The only thing we output or used was a single hardcoded color (the rest was barebone). And that's not a surface shader I might add ;)
Answer by vfxjex · Aug 06, 2020 at 08:22 PM
In case someone bumps into this concern. Just to make it simple, try to make sure your model is below 300 vertices. Take note we are talking about Unity Vertex Count not the 3D modelling software vertex count.
Your answer
Follow this Question
Related Questions
Trouble Understanding Rendering Statistics Window 2 Answers
Is it possible to utilize iphone dynamic batching with "traditional" animated sprite techniques? 1 Answer
Why does the frame debugger say node uses different shader when it isn't? 0 Answers
Drawcalls or Batched, which is more important to performace? 1 Answer
How to know if my Shader Graph is supported by the SRP Batcher? 1 Answer