[Closed][Dynamic Batching] why different uniformly scaled cube dont batch?

HI guys , I am doing a very simple experiment on Dynamic Batching conditions.
I created an empty project , then create 64 unity cubes.
giving them random position and rotation , and make sure they are all within the camera’s view.

I have test 5 cases:

Case 1(default):
Same scale cubes,all uniform default scale
e.g.when all cubes have the same default scale (1, 1, 1). drawcall is 1.

Case 2:
Same uniformly scaled cubes,all using a single random scale k
e.g.when all cubes have the same single scale (3, 3, 3). drawcall is 1.

Case 3:
Same non-uniformly scaled cubes,all using one set of random scale(a,b,c) , where a,b,c are all different.
e.g.when all cubes have the same single scale (1, 3, 4). drawcall is 1.

*Case 4:
Different uniformly scaled cubes,all using their own random scale k
e.g.when all cubes have the scale { (1,1,1) , (2,2,2) , (3,3,3) (6,6,6) …}. drawcall is 64

*Case 5:
Different non-uniformly scaled cubes,all using their own random scale (a,b,c)
e.g when all cubes have completely random scale { (1,2,1) , (3,3,2) , (4,1,7) , (6,4,1)…} drawcall is 1

I checked tje dynamic Bathcing condition from unity offical doc

(case 1,2,3)

(case 5)

Also I found an other way to understand this 2 lines http://blog.xdegtyarev.com/2012/08/unity3d-dynamic-batching-tricks.html

Case 4 failed to batch is because they are not the same scale , also they are uniformly scaled
e.g. (1,1,1) , (2,2,2) , (3,3,3) (6,6,6)

My question is:
If case 5 is possible to batch {(1,2,1) , (3,3,2) , (4,1,7) , (6,4,1)…},
Why Unity dont allow objects with different uniformly scaled batch? ( case 4 :{ (1,1,1) , (2,2,2) , (3,3,3) (6,6,6) …} )

From my understand, dynamic batching means ,
before call the graphic API (e.g. openGL , DirectX) 's draw function , combining mesh’s vertex info together as 1 mesh if they are using the same material.
So if case 5 is possible , case 4 must be possible.
Why unity need to exclude case 4 from dynamic batching condition?

Thanks!

2 Likes

its 2016 now, Unity5 will batch uniform scaling mesh.
e.g.when all cubes have the scale { (1,1,1) , (2,2,2) , (3,3,3) (6,6,6) …},they will still batch.

Scaling breaks dynamic batching will only happen if scaling is Negative Scale,
but only the following 4 case will break batching:
(-x,+y,+z)
(+x,-y,+z)
(+x,+y,-z)
(-x,-y,-z)

No idea why, but that’s what my experiment tells me.(Unity 5.3)

1 Like