x


Batching problem when using multiple materials in one model

I have an fbx model that is using 3 different material for multiple meshes within the model. When I import the model into Unity, make sure the correct meshes are sharing the 3 materials, and check "Static" for the the parent model, I'm having inconsistencies in the batching. Basically, extra draw calls are being added to seemingly random meshes within the model, instead of the expected 3 draw calls (one for each material).

I went back into the model and exported each group of meshes per material separately into their own model files, and then imported those back into unity. When put back into the scene, the draw call count is correct at 3.

Does anyone have any idea why this would be happening?

more ▼

asked Feb 19 '10 at 01:05 AM

Nat Iwata gravatar image

Nat Iwata
21 1 1 2

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

This could happen if you have scripts that are manipulating materials. For example if you set the alpha channel of some item as part of a fade in/out.

When you manipulate a material this way, Unity creates a copy of the material into its own instance - and your link to the original material is lost = extra draw calls.

One way to get around that is to work on the shared material instead. BEWARE - changes here even done at runtime are persisted!! So you want to have some mechanism in place to revert any changes to your original material when start/stopping.

more ▼

answered Jun 24 '10 at 11:32 AM

Thomas Hentschel Lund gravatar image

Thomas Hentschel Lund
329 3 4 14

(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:

x1998
x807
x115
x110

asked: Feb 19 '10 at 01:05 AM

Seen: 1669 times

Last Updated: Feb 19 '10 at 01:05 AM