Static Batching and iPhone Advanced - perfect together?

Ok, I’ve sewn together enough intel from all the threads that touch on the new feature, ‘Static Batching’ and would like to confirm definitively what appears to be the new gain.

In iPhone advanced (not basic), for a series of low poly object, that don’t move, (i.e. houses), that are marked ‘static’ and that share a common texture, there is a net gain in ‘Performance’ as when automatically combines, all those objects would be reduced to a single Draw Call. Is this correct?

So taking this theorem a step further, if I have 14 houses, 14 mailboxes, 14 fences, 14 lampposts, and they all share a common texture map (or is it material with a common texture map) these 56 individual objects, would be reduced to a single Draw Call? Is this correct?

Thanks,
Brendan

Hi.

I’ve been testing this myself recently, and the answer is yes.

If your objects are ‘static’ (they don’t need to be low poly), share the same ‘material’, and if the shader requires only one pass (eg. Vertext Lit) then n * objects will all be drawn in one call. If you use a shader that requires 2 calls then n * objects will all be drawn in two calls.

This is a bit like using the mesh-combine script before with the added performance benefit that individual objects from the same batch can still be occluded if they are not in view, or indeed be enabled or disabled whilst running (saving tris count).

Caveat: I found that the objects need to be already present in the scene for batching to take place, as opposed to being instantiated by code in a start function. Having said this, I believe the latter can still be done by using the new StaticBatchingUtility.Combine function - but I’ve not gone and done this myself as yet…

Hope this helps?

Rob.

PS. It’s easy to monitor if batching will occur in your final build as it is emulated and presented in the Stats overlay…

Rob,

This helps quite a bit. It is the final rational for upgrading to Advanced, now.

Here’s one more question that would be helpful. If I have 6 skinned animated NPCs, would sharing a common material with a common texture map, help save draw calls?

B.

FYI, you’ll find batching related information in the Unity iPhone documetnation. Have a look at the “Getting Started with iPhone Development” section and you’ll see a link for batching information.

That will only work if those characters are 300 verts or less each. Static batching (allows for more than 300 verts per object) requires static objects, skinned characters are not static. If you go with dynamic batching then that happens automatically if you share materials but only for objects with less than 300 verts each.

@brendang

As your NPCs will most likely be mobile in your game ( independent of one another) they will not be ‘static’, so static-batching will not be possible here.

If you can get your NPCs down to <300 verts then dynamic-batching should kick in I believe (even on skinned animated models I think though not tested myself)

  • but <300 verts for a character is very low.

R

(EDIT: Higgy beat me to it - so, ya, as above)

I know my NPCs are too heavy for dynamic batching (~ 1100 faces), though wouldn’t that be nice… Actually I was asking id the common texture map /material would buy back some draw calls.

Tom, you’d be proud, I researched quite extensively before posting. But believe it or not, the sparse parenthetical offerings of the technical documentation are not nearly as enlightening as one might imagine. Kindling user generated banter on these topics is actually quite a bit more insightful, particularly when it comes to the varied challenges of (draw outside the lines), game production.

(How’s that for a paragraph?) :smile:

Thanks Guys.
B.

Sure, you might have but not everyone does and when I answer questions on the forums I have to consider the current person asking as well as future people searching/finding the thread later on so my answers tend to be a bit more generic than the current case might dictate. :slight_smile:

Glad we helped you sort out the information, now rock on!

I need to look into this because I have my own save/load methods. Load reads a file and instantiates prefabs to populate the scene. I’ll be sure to look up StaticBatchingUtility tonight.

Batching of static and dynamic objects is working with out issue on instantiated objects. Batching just works without having to fiddle with anything.

I have a scene with 50 draw calls batched downed to 13. I can destroy and recreate it on the fly and it runs like a charm.

Of course, I haven’t looked at how this impacted the heap and garbage collection yet.

Hey there,

Sorry for digging out an old topic, but I’m testing batching at the moment (I love you Unity for that), and I’m having some unexpected unbatching for certain low vertices objects …

For example in a scene, I got a 52 verts bridge (hat’s what editor says), and an array of 5 x 12 verts building .

The 5 buildings correctly batch into 1 drawcall, but the bridge fails at joining the bandwagon.

All are sharing the exact same material, of course, and are even completely static.

Any clue ?

So same material settings for all? Same texture and you haven’t altered the any of the material parameters on the non-batching object?

Can you post a sample project with just those objects?

Sure, I’ll do that in a few hours :wink:

About material change, I tried to modify material settings for some other objects, like Emissive color or specular amount, and they were still batched.