x


Static Batching HELP!!

Hi, Can someone please tell me why static batching seem not be working properly, I have 4 barrels and 4 boxes all share the same texture, so I thought that with the below screen shot the Draw Call should be 14 not 19 as in the picture, as the one with nothing in screen shows 12 Draw Call's.

If I put the 4 barrels on screen alone the Draw Call is 13 as I'd expect, same if I put the 4 boxes on screen alone, and 15 Draw Calls if I but the 4 barrels and 4 boxes on screen.

I'm confused ??

They all share Mobile/VertexLit shader, tried with just VertexLit same outcome.

Unity 3.5.2f2 iPhone Pro.

alt text

alt text

grab01.jpg (38.8 kB)
grab02.jpg (47.6 kB)
more ▼

asked Jul 15 '12 at 07:00 PM

Griffo gravatar image

Griffo
1.7k 20 48 67

all objects marked as static?

material instance is the same for all objects? not just shader and texture must match

objects have same scale values?

Jul 15 '12 at 10:24 PM ScroodgeM

Yes. Yes. Yes.

Jul 16 '12 at 03:52 PM Griffo

just test:

  • instantiate all objects on the screen and move camera VERY far away from current position, but don't lose focus on objects - notice draw calls changes

  • now try don't move camera and change near clip plane of current camera (leaving object farther them near clip plane) - does it affect draw calls?

Jul 16 '12 at 06:02 PM ScroodgeM
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

I put 4 barrels in the scene that was doing 12 Draw Calls and it went to 13, then I added 4 box's along side the 4 barrels and it went to 16.

I then tried you suggestions and the first one no change still 16 Draw Calls, the second one the Draw Calls went back down to 12.

If I put 4 barrels it goes up 1 Draw Call from 12 to 13 If I put 4 boxes it goes up 1 Draw Call from 12 to 13

Then if I put 4 barrels and 4 boxes it goes up 6 Draw Call from 12 to 18, thats with all boxes the same scale and all the barrels the same scale but 0.5 taller than the boxes, should it not go up 2 Draw Calls from 12 to 14, 1 Draw Call for the batched barrels and 1 Draw Call for the Batched boxes ?

more ▼

answered Jul 16 '12 at 06:34 PM

Griffo gravatar image

Griffo
1.7k 20 48 67

the main issue in your case i see in z-size precision limit. for batching unity sorts all objects by length from camera, and if some objects are placed very close to each other (by z-position from camera, not in XYZ) unity can fail to sort it and batch fails. changing near clip plane changing z-size precision and changes the situation.

finally i havn't a true solution in your case, just try different combinations of camera position and clip planes - there's should be a combination where z-size will calculate correct and you got a picture you want...

Jul 16 '12 at 06:58 PM ScroodgeM

OK will try different combinations .. thanks for you input, much appreciated.

Jul 16 '12 at 07:45 PM Griffo
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x277
x115
x101
x10

asked: Jul 15 '12 at 07:00 PM

Seen: 910 times

Last Updated: Jul 16 '12 at 07:45 PM