So, with the risk of sounding like the noob that I am, why did the profiler report a substantial reduction in triangles, as well as us seeing a small fps boost?
I have a scene that consist of a bunch of separate meshes. The profiler shows
iPhone Unity internal profiler stats:
cpu-player> min: 2.3 max: 4.8 avg: 3.6
cpu-ogles-drv> min: 1.5 max: 2.8 avg: 1.7
cpu-present> min: 4.2 max: 7.7 avg: 5.7
frametime> min: 15.7 max: 17.8 avg: 16.7
draw-call #> min: 5 max: 5 avg: 5 | batched: 40
tris #> min: 9447 max: 9447 avg: 9447 | batched: 7174
verts #> min: 4191 max: 4191 avg: 4191 | batched: 3146
player-detail> physx: 0.2 animation: 0.0 culling 0.2 skinning: 0.0 batching: 1.7 render: 1.4 fixed-update-count: 0 … 2
mono-scripts> update: 0.0 fixedUpdate: 0.0 coroutines: 0.0
mono-memory> used heap: 98304 allocated heap: 131072 max number of collections: 0 collection total duration: 0.0
Exact same scene, except I turn on "static for all but 2-3 objects
iPhone Unity internal profiler stats:
cpu-player> min: 0.7 max: 3.3 avg: 2.2
cpu-ogles-drv> min: 1.5 max: 3.4 avg: 2.0
cpu-present> min: 1.1 max: 17.8 avg: 3.7
frametime> min: 15.4 max: 33.5 avg: 17.2
draw-call #> min: 4 max: 4 avg: 4 | batched: 39
tris #> min: 4804 max: 4804 avg: 4804 | batched: 2505
verts #> min: 4191 max: 4191 avg: 4191 | batched: 3126
player-detail> physx: 0.3 animation: 0.0 culling 0.3 skinning: 0.0 batching: 0.1 render: 1.4 fixed-update-count: 0 … 1
mono-scripts> update: 0.0 fixedUpdate: 0.0 coroutines: 0.0
mono-memory> used heap: 98304 allocated heap: 131072 max number of collections: 0 collection total duration: 0.0
Number of draw calls is lowered by one.
The amount of triangles is almost cut in half.
The time spent batching goes from ~1.5 down to 0.1
I fail to understand why, since not only “In short - it does nothing.”, but since I’m using Unity iPhone Basic, for which static really shouldn’t do anything. So what’s going on? What am I missing?
Dreamora mentioned occlusion culling, which is working in Basic as well, right? But isn’t occlusion culling only for meshes that are fully hidden by other meshes? I have none of that in my scene; everything is at least partially visible.
For starters it’s important to read the manual if folks want to understand dynamic batching and static batching, and in which versions they operate. Dynamic batching is done automatically by the engine for objects with fewer than 300 vertices that share a given material, this is available in both Unity iPhone Basic and in Unity iPhone Advanced, you do nothing to make it happen it just “does”. Static batching is something you must invoke for objects of any vertex count that share a given material, but they must be static and you must mark them as such ahead of time in the editor, this is available in Unity Pro only.
In your case you might be enabling batching, but are the objects in your scene sharing materials? If not then batching really doesn’t do much for you. There is a page in the Unity iPhone docs that you should read if you haven’t already:
Occlusion culling is available in both Unity iPhone Basic and Unity iPhone Advanced, but it requires some set-up work on your part. For that I again point you to the docs as they explain things to get you started:
Advanced > Using Occlusion Culling
Pro-tip: if you want to know what features are in what licenses then check out the following page on our website:
Without further information its impossible to say much.
Whats clear is that batching happens and as he is on basic, its the dynamic batching or its occlussion culling based handling (the tris indicate that assuming he is in the same place)
What kind of information is needed in order to figure this out?
One scene. One material, which all objects share. A few meshes have more than 300 vertices, most don’t. Maybe 3-4 meshes that has more than 300 vertices, and out of those two aren’t set to “Static”.
Dynamic batching should be the same regardless of whether or not we turn on “Static”, shouldn’t it? If so, that means something else is causing the massive drop of time spent batching.
All meshes are always visible in the scene and no mesh is fully hidden by another (although 4-6 something should be cut by the view frustrum). Actually, looking at the scene right now, pretty much no mesh is even partially hidden by another mesh. I think.
Uhm, how do I enable something that is done automatically by the engine? As you said, “it just does”.
I haven’t touched occlusion culling at all, so unless that too, is on by default somehow (which I got the impression it isn’t after semi-watching some unite video on the subject a while ago), so that shouldn’t be an issue here?
You mentioning enabling of static batching had (has?) me wondering whether you’re really using Unity iPhone Basic or Unity iPhone Advanced as it was (is?) my understanding that such an option should only even be exposed in Advanced. Can you go to Unity > About Unity and confirm what it says for your license type? Specifically whether it cites Unity iPhone Basic or Advanced? On my end I’m going to swap my license type back to Basic and test myself.
Edit: and there you go, the “static” option is right there, even in Unity iPhone Basic. Hmph. That leaves me stumped…
It’s not going to do anything automatically, as I noted above you must take some manual steps to set things up then calculate, ahead of time (saving the run-time cycles) occlusion volumes. So I don’t think this is at play so much as something to do with batching, hence my question about what type of iPhone license you’re really using.
Static is present on both Unity iPhone licenses as it forms the base of the occlusion culling.
Though the batching should be disabled in the iphone basic license, in 1.5.0 users were bombed by the corresponding error message in the log over and over.
Question is if the fix for that message potentially also included static batching for iPhone Basic, without beeing meant to do
I have Unity Iphone Basic, yes. And I haven’t touched the occlusion culling either, so something else is going on here. And it IS a substantial difference in performance, so would be hot to understand why.
I have 7 draw-calls if I use Combine Children on a group of non-moving scenery objects to combine them. If I turn off Combine Children I get 15 draw calls.
If I turn on static for these objects (instead of using the combine children script) then my draw calls drop to -12 (yes minus 12).
I get this approximate behaviour in both 1.5.1 and 1.6.
I can’t say I’ve noticed any performance benefit in the game though.
Also, if I use both the combine Children script and Static the objects don’t get rendered at all.
In the profiler:
Using Combine Children reduces draw calls by one compared to Static but the mono memory is drastically increased (I guess for the extra geometry being rendered compared to Static).
So I reckon Static IS present in 1.6 and 1.5.1 iPhone Basic - using the IDE boolean switch (maybe via scripting doesn’t work).
I’m a little surprised that the Combine Children script results in lower draw calls than Static though. Sometimes using Combine Children might be better than Static (to save the extra draw call)?
Apparently there is no batching when using primitives. Just replaced my sphere primitives with a real mesh and suddenly the batching process kicked into overdrive.
if the primitives use the same material they will batch, as long as it is not the sphere cause that thing has so many vertices that it crosses the allowed num (for the sphere I would recommend to model an own one and make it a sphere prefab)