How does Static Batching work in Unity 3 on PC?

I’ve just discovered a change between Unity 2 and 3 which has caused me a few hours headache.

I’ve been using hte following code to get the mesh from an object:

MeshFilter meshFilter= GetComponent(typeof(MeshFilter)) as MeshFilter;
Mesh thisMesh = meshFilter.mesh;

Worked fine but then stopped working when I tested with Unity3. When I checked the mesh the code returns it is huge, (About 150,000 verts instead of the 300 which is should be) further investigation showed it had been combined with other meshes in some way. Turns out there is a check box in ProjectSettings/Player to toggle StaticBatching and DynamicBatching and they seem to be on by default. Turning off Static Batching solved hte problem.

Now there are a few things I don’t understand:

  1. According to the manual this option is only available on Iphone OS but I don’t have that so why’s it there?
  2. I thought static batching only combined meshes with the same material but the objects I’m testing all have unique materials so how is it combining them into such huge meshes?
  3. when I turn of static batching it doesn’t seem to effect the frame rate - so what’s it doing?
  4. what does Dynamic Batching do? Didn’t seem to do anything when I turned it on or off

For now I’ve turned off both types ot batching but the manul seems pretty vague on this issue and it would be good to know what’s going on

regards,

Tony

I’m seeing something similar in a pretty big scene. It really hit me when the verts peaked 1.5M and a sum of all verts in the scene was around 700K. It looks like something in the combine was causing a large increase in the total number of verts. Oddly enough combine children on parents with this setting disabled resulted in the same ballooning of verts. A quick model pass seems to have fixed both. Sure the draw calls were down quite a bit, but I really didn’t have an issue with that to begin with at around 1400 DCs (reduced to around 700). An update to this would be REALLY appreciated as would more info on umbra occlusion culling settings.

Agreed.

Since Unity 3.0’s launch, it seems the dev’s have been very busy as many questions concerning beast + umbra problems are left unanswered.

I’m guessing something to do with a possible 3.1 release at Unite and the rush to finish it before that.

  1. Incorrect, with U3 its available on all platforms. It was iOS only with iPhone 1.x and U2
  2. Static batching will combine it up for all. The material requirement is for dynamic batching
  3. either you don’t have shared materials in which case it does nothing or you do have but have a cpu and gpu thats strong enough to not reach the bottleneck of drawcalls and switches with distinct meshes. weaker systems will show a difference
  4. then you don’t have dynamic meshes in view or nothing that can be batched (not the same material, you have skinned meshes which don’t batch, …)