Does anybody know a definitive guide on combining models for batching?

Scripts, sharing materials, etc. What are the absolute best practices? Does anybody know how the fantastic Madfinger handles this?

(Given that I’ve already studied the following: ShadowGun: Optimizing for Mobile Sample Level | Unity Blog)

Follow-up: Any definitive documentation or experience on how dynamic batching works? I’m a little confused.

All the best,

–Rev

I don’t know of a definitive documentation for dynamic batching, but if you Google this list with “Dynamic Batching,” you will get 1000’s of hits. An hour of reading will give you a pretty good idea of what works and what doesn’t. Here are the high points I’ve gleamed:

Won’t work:

  • If the materials are different, the objects do not batch.
  • If you change any material attribute at runtime (color, texture, offset…), then the object gets a new instance of the material, and that object will no longer batch with the objects using the original material.
  • If you have more than 900 vertex attributes in your mesh, then the mesh won’t batch. For example if you are using both normals and uv in a mesh, then you can only have 450 vertices and have the object batch.
  • Submeshes that use different materials don’t batch together. Different material means different GPU call.
  • If you use Graphics.DrawMesh() to draw your mesh directly, the meshes don’t batch (even if they would batch if attached to a game object).
  • Sometimes objects that on paper should batch don’t for reasons unknown (or at least uncommented upon) to the list.

Will work:

  • You can change UV mappings at runtime without breaking batching.
  • You can change the vertex colors at runtime without breaking batching.
  • You can change the mesh itself at runtime without breaking batching (assuming you stay under the vertex limit).

One best practice: look into texture atlases to reduce draw calls.