Why is it possible to add additional materials to a model, beyond its sub-mesh count?

Just discovered that you can arbitrarily add additional materials to any model, beyond the number of its sub-meshes. This seems pretty strange ass technically it doesn't make much sense, since the purpose of sub-meshes is to allow efficient batching of a single model by shader/material.

Yet in Unity Editor you can add additional materials which are applied in additional passes by the looks of it, to the last sub-mesh in the model. This means if you had a single mesh model that you could add a second material to 'adjust' the first, say blend a colour over it.

This could be quite a cool feature, but as I said its not something I would have expected. So is this by design or just some quirk that may be fixed in future releases, thus maybe dangerous to rely on.

Just to be clear I am NOT asking about why a model can have multiple materials ( via splitting into sub-meshes per material/shader). I'm asking why you can add MORE materials than the number of sub-meshes in a model.

For example, open Unity and load a model with sub-meshes into the scene hierarchy. Lets say it had 3 sub-meshes/materials. In the inspector (make sure model is selected in hierarchy) you can change the material count from 3 to 4 or greater. Unity will duplicate the last material and the last sub-mesh will now render using both materials (presumably via 2 passes). You can keep adding materials, though they will all be applied to the last sub-mesh only.

This is by design.

An example of how to use this would be using 2 separate material ID's on the same mesh.

You can do this in your 3D Modeling application such as 3DS Max by selecting faces of an Editable Mesh/Poly and setting it's material ID to an arbitrary integer. From there a sub-object material could be created and multiple materials applied to the same singular mesh.



I'm pretty sure it's by design, and it's something I use pretty frequently

My own personal experience is to use it for a layered clothing system - I add multiple cutout materials over a base diffuse layer to get different sets of clothing

Unity doesn’t appear to support multiple materials per mesh, any subsequent materials are always greyed out so what I do is split the mesh and do it that way

Here’s how I’m using that. I know that my mesh will have UP TO 5 submeshes. But at times it might only have 1. So I preload it with 5 instances of my material. Then I can programmatically define the number of submeshes I need at any given time and add them. I could add the materials as needed also but in this case chose not to.