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?
asked Dec 16 '10 at 12:26 PM
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.
answered Dec 16 '10 at 07:24 PM
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.
answered Dec 17 '10 at 06:33 PM