Use mask from image editor in shader tree

Hi,
is there a way to use a mask in the shader tree?
I don’t mean a black and white image or something like that but the type of mask you can make in the image editor when switching from “view” to “mask”.
The ones you can use for example in the compositor:

You need to map the mask to the object faces to have it change the shader. If I understand what you want, you’d like to draw a mask projected from the view? If so, here’s how you could do that:

Draw the shape of your mask on a BW image. Then use the camera texture coordinate to project it.

Play with the mapping node to move it where you need it.

There is no workaround to having an image be the shape of your texture, it could be vertex painting, but I doubt that you’ll be able to have the freedom you want.

I hope this helps a bit

No, I would like to use the mask feature in Blenders image editor. I want to avoid drawing completely. See the image I attached in my first post. Go to the image editor and select “mask” from the little drop down menu which I marked red.

It has nothing to do with using it from a specific perspective. I see where the confusion comes from, though. The image in the lower part of my attached image above is a render piped into the image editor.

Here is an image that might make it more clear:

Can you quickly draw an example of what you want the result be like? What would be the effect of the “mask node” on your cube? If it is to determine an area to be a different color, like I said I believe that using an image is the only way.

If you want to use the mask feature, you can render both colors and use a mask in the compositor to show either result.

I want the result to be the same as with a black and white image map.

The only difference would be that the mask can be easily animated while animating the black and white image requires a whole image sequence. It is of course possible to create such an image sequence but it is vastly more work to do so than simply animating a mask.

Oh I see, and does the mask you want to animate deforms itself or does it only moves?

That depends. I have no specific use case in mind here. I am trying to figure out if this workflow can work in general.

I mean, if it only moves/rotates/scales then it would be relatively easy to do it with the mapping node.
Deforming masks however require either an image sequence or an elaborate math node setup which both takes a lot more time than animating a mask.

Similar to Object Info, Particle Info and Attribute nodes, you need a dedicated Mask node input for the shader tree that also takes an UV node input, and this doesn’t exist yet. Would be cool to have.

1 Like

I am not very familiar with the image editor. Is it perhaps possible to convert a mask to an image on the fly, so that you could use the converted image in a normal image texture node?

The Mask in the Image Editor is called in a Mask node in the Compositor, and I have used it for editing images before, but just like everything in the compositor, forced update by playing timeline to animate between keyframes.

I haven’t seen any work to allow the Compositor pipeline to affect the Shader pipeline directly, though I have asked for it several times on RCS. I had hoped we would be able to do complex texture adjustment in the compositor and send to a special texture node in the shader tree.

1 Like

That would be great but I assume it is not easy as it would be prone to dependency loops.

1 Like

Yes, but if you had a button to lock the render similar to how you bake and free particles, that could work.

Would it be enough to make it impossible to pipe compositings back to the scene which come out of a “Render Layers” node?
Or actually only from “Render Layer” nodes of the same scene.

I’m not sure, just always envisioned that we could have a separate compositor type that would specifically be used for textures similar to the old brush texture editor but with more of the main image editor functions as well.

1 Like

Sounds good to me.

So I wonder if what you’re looking for is like the 3ds Max/Arnold “clip-geo” which is a brilliantly useful shader and I hope it makes it to the blender dev request list, or if a Blender “holdout” shader would work? Are you trying to have the source object make a hole? Or cast a shadow?

I am trying to use a mask:

inside a Cycles shader.