Best way to get custom masks of polygon islands for use in 2D image editors?

I often use tagged polygon island selections in another application to create masks I can render out and use in 2D editing software (PS, Affinity etc.).

For instance, say you are rendering out an image of a phone, but you want a custom mask for just the top polygons for the power button so you can make it a little brighter with a curves adjustment etc.

The best way I’ve found yet to do this so far in blender is to:

  1. Create a vertex color attribute for the object
  2. Vertex paint the parts I want black and white using ctrl x (set vertex colors)
  3. In ViewLayer, add a shader AOV
  4. In shading, Add an Attribute Node, give it the right Attribute name, and connect it to an AOV output node with the right name
  5. Render, save out the AOV pass

Is there a faster/better way to get polygon selections as masks at render time? I don’t like using material IDs and magic wand etc. selections in 2D editing apps as those aren’t always very precise.

So no cryptomatte?

You don’t have to use vertex colors, any color output will do

Will cryptomatte pick up vertex attributes? I thought it didn’t in Blender so I didn’t try it yet.

I can use a PS plugin to read cyrptomattes and break them out into masks though if it does. :+1:

That’s true, but I need a way that doesn’t interfere with my shading and is independent of material assignments. Using a attribute map with vertex colors means I can make selections across different material areas of a scene/object and create a mask from it.

I guess I could create an image based mask for the areas, but then that requires UVs, isn’t resolution independent etc and I’d have to keep track of the images.

Maybe I’m misunderstanding though what you mean?

Vertex colors are flexible, but you can pipe any color.

It doesn’t have to be part of the rest of your material. You haven’t specified what you found impractical with your current approach. If it’s creating the vertex color layer, then you could do a linear demarcation with something like : geometry node position output → math greater than → AOV output.

I am not sure what you mean by that. AOVs are defined at the material level in any case. If that is impractical for you then I don’t have an alternative sorry

Thanks for the information and reply!

The only issue I have with the work flow I’ve figured out is that it’s a bit slow to setup and use, so I was wondering if there were faster ways to achieve the same results.

I’ll look into the method you’ve outlined with geometry nodes. :+1:

The AOVs are at the material level which is fine, but I was trying to say I can use them with vertex maps and not interfere with my beauty passes etc to get masks.

I meant the node called geometry within your material. It has a position output that you can use to mask out parts quickly. But on second thought, it works in world space so it’s not the best (it doesn’t follow object transforms). Try using the texture coordinate node’s object output instead.