# Best way to paint same Material with different mask?

My question is to have an alternative way if it exists. So my problem is the following: As you can see from this image, I have 2 materials, the first in the top row, uses vertex paint, so white and black decide how to mix green and red, so everything is ok here. In the row below, there is a material practically the same, but which uses a mask (Always black and white) for vertex paint which is absolutely more detailed, as it does not need to have a high subdivision of polygons (As in vertex paint) .

But there is a problem in Texture paint, unlike vertex paint, that is, the possibility of painting the same material on many objects, without these being modified all together, let me explain better,

The vertex paint refers to the colors of the vertices of the object, but is very limited on the final results, due to the triangulation that is very visible, but remains independent (If the object is not an instance)

The texture paint is very nice, but it does not remain independent, so if I paint an object, the other object with the same material will suffer the same fate, therefore I will have 2 objects with the same mask.

I'm trying to approach this to understand which way to go, without having to create a new material, but probably my knowledge stops here.

Basically, I would like to have only one material, with the possibility that it can be masked independently on objects.

I would also like a vertex paint solution, if this were not so "Squared". I have a lot of confusion right now and I would like to know an answer on this, which will guide me to a "Logical" but intelligent choice, always keeping the single material

Post Bounty Note:

Based on Splize's answer , however, I thought that this method could contrast with the real use of Index pass? but actually it seems a very useful answer, and it works very well. At this point I would like to understand if there are further way that can be taken. Taking into account also a hypothetical more detailed vertex paint, because the vertex paint is much more "comfortable" as it does not require an additional Mask and "Smart Projection" to make the correct mask mapping

• Unfortunately, Vertex paint requires geometry subdivision to work well with smoothing the paint. You only get the detail you are willing to have geometry for, as the Subdivision Surface and Multiresolution modifiers do not allow you to paint after the result of the smoothing. You could however look into combining the texture paint solution and UDIM paint schemes for allowing multiple textures to be used in the same material. – Craig D Jones Jul 6 '20 at 15:52
• Indeed there seems to be no alternative solution, as vertex paint, as the word itself says, refers to the color of the vertices. It is a pity that there is no trick to overcome this problem of resolution. But I understand the limitation and it also makes logical sense. I don't understand what you mean by: quote "You could however look into combining the texture paint solution and UDIM paint schemes for allowing multiple textures to be used in the same material." – Noob Cat Jul 6 '20 at 22:22
• Can you be more specific what is the reason to keep it in a single material? To better understand what alternative can fit to your needs. Thank you – vklidu Jul 6 '20 at 23:30
• UDIM allows one to have multiple UV map positions and it could be possible to use UV Warp Modifier to change the position of the UV across multiple UDIM mapped image, though I am not skilled enough to fully realize it given the unknowns in your project use case. – Craig D Jones Jul 6 '20 at 23:59
• Complex material stored in Group is possible (in general), but if you want to keep listed only one material ... OK. BTW If you want to attract more visitors I would suggest to revised the Q description, that is unnecessarily long and a bit confusing. – vklidu Jul 7 '20 at 7:31

You could use the "Object Info" node for that purpose. It has an output slot called "Object Index", which actually refers to the render pass index found under "Object Properties" -> "Relations":

You can give each object an unique "Pass Index" and then identify it in the node editor with a math compare node that will output "1", if the input "Object Index" (same as "Pass Index") matches the value specified underneath and "0", if this is not the case:

These outputs can then be used in a "MixRGB" node to attach the appropriate mask textures to the objects.

• This technique looks very very interesting! I have to delve into this example to better understand how to manage it – Noob Cat Jul 4 '20 at 23:28
• I gave the bounties to your answer, as it is the most faithful to my question, as there is no need to create further materials. Although it would be nice for peter to access a custom property instead of object index. But it seems that this is not possible – Noob Cat Jul 13 '20 at 19:46

You will have to specify some kind of "mask" at some point of process for any object. So I'm not sure if the shared material is key for you.

If you want just be able to change node-tree shared by multiple objects from one place you can use Node Groups. Place all material node-tree into a group (Ctrl+G) only "mask" node and Material Output place out of this group.

Once created, the node group can be placed (Shift+A > Group) everywhere and managed from any of its copies. This way you can completely change node tree into totally different look without touching material with mask specific to object.

• I find this very interesting, but I would like to keep the same material (as in my question), although I think this is a good alternative – Noob Cat Jul 6 '20 at 22:55