- Home /
The question is answered, right answer was accepted
Multi materials for one mesh
I need to be able to change which faces use what material during run time, on a single mesh. I need a way for each face on a mesh to be able to change from green to transparent, be two different materials, or a shaded of some sort. The problem is being able to define which faces use which shader, or colour. How do I do this? Thanks.
I would think the material is bound to the mesh filter so if one material on a mesh it will take care of the whole mesh.
You would have to cut your mesh in sub models.
I could be wrong though but most modelers d it that way so there must be a reason.
Huh. That's a shame. I'm making a city builder, so I need to make some faces turn transparent when a subway station is plopped down, otherwise the ground covers it over. The zone is about 500*500 tiles, so that would be about 1 million vertices if there was a sub mesh for each grid space. :(
Could you have one shader that turns a face of the model transparent if a Boolean value is true? So if transparent= true, it would turn the face alpha to 100%, but only for that face and not the whole mesh?
It's possible to make certain parts of the mesh use one of the object's materials. Look into Sub$$anonymous$$eshes, these are basically arrays that take vertex indices just like the normal triangle array of a mesh, but you can have multiples. They correspond to the material array of the renderer.
As I wrote above, you have to look into Sub$$anonymous$$eshes. Understanding the basic $$anonymous$$esh class is a must.