Batched draw-calls

Hey, all,

I’m struggling to get my head around what’s going on in my current game with Batching.

Basically, in order to make the most of camera culling, I’ve split my world model (which uses 3 materials over the entire world) into multiple smaller objects, all of which are < 300 polys.

With everything turned on, my drawcalls are 15, with 20 batched (surely batched should always be less than total draw-calls too?) and then, when I turn off one of the object types which uses a single material, the drawcalls change to drawcalls 6, batched 16.

What this means is that, even though all the objects I turned off (about 20 of them) are < 300 polygons, and all use the same material, I’m not seeing the reduction in draw-calls I’d expect.

Surely, if what I say is correct, the difference between the first situation and the second would be 1 draw-call? So with everything turned on, I’d have 7 draw-calls, and with the single material objects turned off, I’d be seeing 6 draw-calls?

The material in question is a “Fast diffuse”, so it’s not even as if my material is multi-pass or something…

Am I missing something?

Cheers,

SB

Hiya - remember that dynamic batching hinges on 300 verts, not polys, so it’s possible you have a collection of objects where only some fall under the batch threshold. I have a feeling this is causing most of the confusion here about your profiler totals.

As for what the profiler reports, Drawcalls = just that, total # of drawcalls for a given frame. Batched = how many total objects are being batched.

Think of it this way: take an empty scene, and add 1 cube. Drawcalls = 1, Batched = 0.

Add another (default) cube: Drawcalls = 1, Batched = 2.

Add two more, Drawcalls = 1, Batched = 4. (This is why you’ll see Drawcall# < Batched#).

If you add another batchable set of objects with a different material, however, you’ll get another drawcall but another set of batched objects going on towards the batched object total.

See, this is the issue.

I’ve just been experimenting some more, and have found other stuff I don’t really get.

My “player character” is made up of multiple different game objects - all of which are different shapes and sizes, all below 300 verts, all using one of 3 different materials.

When I turn everything other than the player character off, I get:

Drawcalls 13, Batched 15.

The 3 materials on this object are:

  1. Fast diffuse
  2. Sprite cutout (as it’s the cleanest for textures with “holes”
  3. a 2 pass texture for “glass” effect

With that in mind, I’d expect a maximum of 4 draw-calls (1 for diffuse, one for sprite cutout and 2 for glass). There’s literally NOTHING else on screen at this point, so the 13 drawcalls is really confusing me…!

Also, I’ve just checked the original mesh I was talking about, and there isn’t a single object in the entire scene which has > 300 verts.

As I’m only using 6 materials between the player character and the world, I should surely be expecting no more than 10 draw-calls, even with my multi-pass shader, no? As it stands, I’m getting closer to 35! :frowning:

I believe there can be problems batching when using transparency. A search for that may help you.

Nope - even if I convert all materials to DiffuseFast, they still produce a lot more than the expected draw-call numbers…

Any other ideas? This is in Unity 3 beta 7, by the way…

I read one of the beta versions showed the wrong nmber of drawcalls in the editor. Maybe it’s just that?

Currently the batching has some probs on U3 betas

prior to b5 batching was not present, with b7 its a bit over aggressive and was mentioned to be fixed again.
what is no longer batched (and that was mentioned to be by design) though are skinned meshes.

Yeah, not too worried about that - my game uses no skinned meshes…

Well, here’s hoping it is a bug, then - the amount of draw-calls is extreme to say the least! :frowning:

Uh?

I hope this has been carefully measured to perform better without batching … I have a lot of skinned meshes with a few bones that used to batch very nicely in the old versions.

I cannot verify the real performance on beta7 because with dynamic batching I get mostly random flickering stuff in the phone at the moment :slight_smile:

br,
Sami

What in the world!!! I suspect there is a different way coming in replacement? These Unity 3 changes are just baffling to me…

for 3.0, definitely not as it was removed on purpose.
later, we will see.
generally it does not make a difference out of my experience with 16 skinned mesh renderers active. U3 rendering works different enough for batching to have different performance consequences than before.
Up to b5 or so there was no batching and yet U3 still outperformed iPHone 1.7

OK, then if you say so…