multiple masks on one image texture?

Is there a way to map different shaders/textures to specific RGB or hex colors on an image mask? For example, anywhere on my mask image that is the color #3c3c3c would be my glass shader, anywhere that is #ff0000 would be my wood shader, etc.

I have been doing some experimenting with the seperate RGB node, using it to make a single image texture with 3 mask colors. Usually I’d do a black and white image, or use an image alpha to mask. However, when trying to layer textures, you quickly wind up with several images because you can only do one at a time with that method.


Hmm, interesting. Why are you trying to do this with only one image? Is it an issue of trying to save memory? It seems like a multichannel image like that would be really non-intuitive to control.

I think you could do up to three with RGB, each one acting as the mask for one input. However I don’t think you could do a very specific color like #203b7b very effectively. You could set it up so that any areas that are EXACTLY that color would be masked, but you couldn’t do any blending.

Rather than have separate shaders mixed with a factor, you can have one shader which has variables driven by image maps. For instance, say you have an object with shiny metal, shiny plastic, rough plastic, rough metal, wood, fabric, and rust. That could be done with one node group that has color, roughness, bump, and something like “metalness” inputs. Each input is driven by an image map. So the fabric has a different color, roughness, bump, and metalness than the metal area and is also different from the plastic etc.

From a rendering perspective this is only 4 maps which should be able to cover basically any non-transparent material, and it’s way fewer shaders than having each material be separate. Of course if you want to bring in transparent or subsurface scattering materials you will need a map for that distinction, but even then you would basically only need two more maps bringing it up to 5 total. You would use the same set of color/roughness/etc maps to distinguish between various types of glass.

No specific reason as of right now, but in the future I think I could find usage for it. It will cut down on memory to only have one image, with all of my different materials mapped to different colors. And yes, I’m able to do 3 with seperate RGB, but I feel like it could be taken a step further if the ability to use hex or rgb was available. Here is my experiement set up. You can see on the right hand side my image map, with red, blue and green. I then have 3 different node set ups, one mapped to each color.

Here is a .blend for anyone interested:


The problem with RGB values is how do you describe areas that are not fully one or another material, but a blend. Problems are the same as with hue keyer, it is not easy to get a good mask by defining a color range that is a mix of different RGB values. If you can separate your color ranges that describe different masks so that you can extract them later in the shader, use them if you have to. But imho using simple RGBA channel masks is much easier to set up, debug, understand and create.