I'm trying to work out a way to generate a mask based on a color ID texture in the material editor (not the compositor). What I'm trying to achieve is have a node group I can re-use which has two parameters, the first parameter is the color ID texture and the second parameter is the color from the texture I want to generate a mask from.

I've included an illustration: enter image description here

I got it working for some colors (such as red, green, or blue) but it didn't work in all cases, I also had a problem where the mask would show up properly when previewing it through an emissive shader but wouldn't show up when viewed through a normal diffuse shader.

Thank you for your time.

  • $\begingroup$ so do you need to improve that IDtoMASK node to work with all colors ? $\endgroup$ – Chebhou Feb 15 '15 at 13:29
  • $\begingroup$ Exactly, it has to work with any input color, basically I need it to extract the selected input color from the color ID texture and output a grayscale mask. There's a similar node in Substance Designer but I don't remember what it's called. $\endgroup$ – Spiderhund Feb 15 '15 at 13:41
  • $\begingroup$ see the answer and adjest its output to get gray scale , i get some work to do now $\endgroup$ – Chebhou Feb 15 '15 at 13:47

Two independent node groups for creating a mask based on a color and a texture :

material setup :

enter image description here

the first node group outputs boolean 1/0 ( all comparisions are "less than "):

enter image description here

the second node group outputs grayscale :

enter image description here

adjust the sensitivity/clipping to get a good result "sensitivity is added to overcome errors due to rounding the numbers"

  • $\begingroup$ @Spiderhund use the eyedropper to pick the exact color from the uv/Image editor $\endgroup$ – Chebhou Feb 15 '15 at 13:49
  • $\begingroup$ Thank you for a quick response! It works much better than what I had before, I noticed that it selects multiple colors though, for example if I choose the orange color it actually selects the blue color instead and if I choose the blue color it selects both the blue and the cyan color. $\endgroup$ – Spiderhund Feb 15 '15 at 14:06
  • $\begingroup$ @Chebhou can this be done without separating colors with something like vector math? $\endgroup$ – Bithur Feb 15 '15 at 14:06
  • $\begingroup$ Alright if I add an inverted between the "Absolute" node and the "Greater Than" node I can isolate the exact color I want using the sensitivity slider. Thank you for your help! $\endgroup$ – Spiderhund Feb 15 '15 at 14:32
  • 1
    $\begingroup$ @Chebhou Thank you! This is exactly what I needed! $\endgroup$ – Spiderhund Feb 15 '15 at 16:08

wow, i used an other method but mine is so small i'm ashamed of how simple it is :), but i have tested it with different shades of some colors like dark blue and light blue and it worked well. anyways its like thisID map mask node


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.