x


Multiple materials for multiple submeshes

Hi,

I have been using the fact that MeshRenderer's materials is an array for two things :

1) Render a mesh with multiple submeshes, each with its own material 2) Render a mesh with one submesh several times, each time with a different material (for example, adding a rimlight effect to the model regardless of what the main shader is)

However, I don't know how to combine the two. I have a model with two submeshes, and I want to render one of them twice - once with each material. That means a total of three materials. I tried putting the three materials in different orders, but could not get this effect.

Is this possible?

more ▼

asked Dec 16 '10 at 12:26 PM

Noam gravatar image

Noam
282 24 24 33

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

2 answers: sort voted first

Occam's Razor: Split the submeshes into multiple meshes.

Aside: I don't know how it works in Unity, but in the last game engine we used "submesh" was used to describe draw calls that were not interleaved with material/state switches, which required them to all have the same material.

more ▼

answered Dec 16 '10 at 07:24 PM

Max Kaufmann gravatar image

Max Kaufmann
588 10 12 21

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

Unity does not currently have the capability to do what you want, without a little bit of extra hassle and stored data. You need to rework the mesh so that it has three submeshes. If your modeling tool doesn't permit assigning the same triangle set to two materials, you can make an Editor script to copy the triangle indeces from one submesh to a new one.

more ▼

answered Dec 17 '10 at 06:33 PM

Jessy gravatar image

Jessy
15.7k 72 95 198

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

x1404
x841
x281
x21

asked: Dec 16 '10 at 12:26 PM

Seen: 2752 times

Last Updated: Dec 16 '10 at 12:26 PM