I am importing a RGB image into Blender and I would like to replace the colors of the image by materials (Glossy, Glass, or other complex Node setups).

enter image description here

For example I would replace the green with an iridescent material, the blue with a concrete texture, the red with a Glossy shader, etc...

I haven't found how to do that because I am not sure how to plus these directions into the image texture. I looked at my previous similar question, but this image I am working with now has no Alpha layer.

  • $\begingroup$ The answer here gives a 'Colour ID' node group setup that can be used to automatically convert any block colour in a texture map to a black and white mask (not just RGB colours). The output can be used as the factor input on a Mix Shader node for more complex material setups. Might be what you're looking for? blender.stackexchange.com/questions/24796/… $\endgroup$
    – Hexbob6
    Nov 15, 2017 at 1:30
  • 1
    $\begingroup$ Do you want to mix three base materials depending on how much R, G and B each pixel has (and, in this case, do you want only proportions to count or also global intensity, and how)? Or is your image made of only full-R, full-G and full-B pixels? $\endgroup$
    – Nicola Sap
    Nov 17, 2017 at 11:41
  • $\begingroup$ I would like to be able to import an image (for example full color photo) on which are color elements (full-R/G/B or not, several or just one) that stand out and can be singled out to turn them a material (glossy, transparent, emission, etc), ideally without losing quality on the rest of the image colors. But it could be an array too i.e. making all flesh tones in an image or video emission or glossy. $\endgroup$ Nov 17, 2017 at 19:43
  • 2
    $\begingroup$ Related question: How can I use colours to separate texture node treatment? $\endgroup$
    – Carlo
    Nov 19, 2017 at 0:20

1 Answer 1




Example with Glossy, Glass and Emission shader.

Overview and Node setup:

You can do this by Separate RGB node which, well, is separating RGB channels. Then use them as masks for your materials.

Important thing is that it would work even better if colors of the image would be pure RGB values. For example now red channel is R: 0.85 G: 0.43 B: 0.43 and should be R: 1 G: 0 B: 0.


As a workaround for those color issue, you can add Math nodes and set them to make channel only black and white (white should be selected channel). Example for green channel:



1. Different materials.

You can change Diffuse shaders from original answer to any shader you want. They can have Image Textures, procedural textures, Bump Maps, anything you would normally do with texturing objects.

enter image description here enter image description here

Going further with this:

I've created Node Group from original answer to make it even easier and less distracting for you:


As you can see here Image Texture is pure RGB and accordingly to the channels there are connected Principled Shaders (could be any shader).

Tweak Values are for non-pure RGB colors.

Blend file:

2. Different colors.

Simple answer is - no. You can't use this setup for images with other colors (except for black). There is possibility to create such setup but it will be mostly based on specific image rather then making one to rule them all.


This is because all colors are RGB based. You can try with Tweak Values but it will be pretty hard.

Also you can use only one color with this setup but only if everything else (background) is black.

  • $\begingroup$ Hi! Thanks for the answer. Can you explain what the values in the subtract nodes do? Could you post the node setup that leads to the first image of your answer? Thanks! $\endgroup$ Sep 18, 2017 at 18:16
  • $\begingroup$ Also, can you use the image to use different materials (including displacement, etc) on the place? $\endgroup$ Oct 13, 2017 at 23:06
  • 1
    $\begingroup$ @MicroMachine Check my edit. $\endgroup$
    – cgslav
    Nov 14, 2017 at 22:23
  • $\begingroup$ Thank you for this technique. I'm using it to paint a landscape model and find it very flexible and intuitive. Just a few points from my specific use: 1) Effectively this can be a 4 colour system including black. In fact black is the easiest colour to use because you can paint over anything. With other colours, if you want to paint over a section, you need to give it a black "undercoat" first ;-) I use black as the base colour (a rough rock), then paint over that with red (sand), blue (a smoother rock) and green (vegetation). cont ... $\endgroup$ Jan 17, 2018 at 11:12
  • 1
    $\begingroup$ ... cont. 2) If using image textures, the 2nd value in the math nodes should be 0, assuming you want the textures to be clear. 3) Painting colours over each other then works quite well; e.g. blending sand into rock or rock into vegetation. If you'd like to see a screenshot of my process: i.stack.imgur.com/NXghF.jpg $\endgroup$ Jan 17, 2018 at 11:13

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.