Mapping Shaders According To The Colors Of A UV Map ? ?

I’ve basically been trying to map some shaders on a mesh according to pixel color values in a UV image map.

for example,

if i started with this image:

then created a mesh and unwrapped it accordingly:

would it be possible to instruct blender to render shaders in place of the different colors, similar to the image below?

Thank for your help!

Try this.
There is probably a better way to have more control if you have a more complex image, but this seems to work with yours.

you could also assign a mat to each color and then you can shade it as you want !

happy cycles

Thanks! That worked very well!!

I intend on only applying this method to some models of printed circuit boards im working on. i believe that i would only see 5 to maybe 7 different types of layers at a time. The software i am using to design the boards always exports with the same color pallet, so once this material is configured correctly it should be able to be applied to multiple PCB’s without too much effort (i hope…). though i will look into optimization and hope to use this nice little trick for years to come!
Thanks again Rich,
Blender rocks!

You can always use a separate RGB node for this, this will output three masks based on the different color channels in the image (which you can use for masking). Blender 2.69 will also have a separate HSV node as well for even more possibilities.

I am very interested in this method you speak of! but unfortunately I would not know where to begin. are there any links or terms that you might know of that i could search for?


selet the faces for one color then in the material panel
add a new material and assing it to these selected faces
then do the samethng with other faces
unitll you have the qty of material you want!

then in cycles for each material you can add a shader as you want!

happy cycles

Oh! I think i should have used an actual model from the PCB design suite in my first post.

Unfortunately the mesh generated during the export is less than ideal. It becomes very triangular and very hard to manage.

this is the actual output:

Assigning whole different materials will only work in your first example, because each color maps entirely and exactly to specific faces. With your latest pcb texture, imagine if you had to have toplogy that exactly matched the shape of each bit of text and each circuitry line. Assigning multiple materials would be a terrible technique for what you have in mind.

I have made some alterations to Rich’s node setup and these are some results:

These allows the user to select the exact color using the “dropper tool” and then define a threshold value (~0.1 - 0.01) above that color’s B/W value.

it seems to work as expected for me, but to anyone who does try this Should Be Aware:

  • The order in which you select your colors is essential! it must always be brightest to darkest!!!
  • Where there are sets of two values that then are connected to an “Add” node, it consist of the target color and a value of roughly 0.1 (the positive match threshold).
    if you find that you have two target colors which are very close to each other in the grey scale spectrum, then consider making positive match threshold smaller/tighter or even try adjusting down one of the target colors which will move the range in a negative direction.

My first render of the EagleUp Demo Board:
Click here for more information about the EagleUp project

Also note each “Sub Material” that you would like to have must be created and defined in the same nodes that do this whole cascade of comparative “Less Than” statements. i am not sure how to define some material nodes elsewhere and bring them in as maybe a group…?

High contrast, shows good isolation between the different layers. all shaders here were just simple diffuse colors but still looked cool!..

More optimized setup –

And finally something somewhat realistic! :smiley:

ok but how did you do it
just add a pic UV map ?


correct! it was quite easy to apply this method to just about any simple uv mapped mesh so long as you limit how many colors you use to define your shaders as it could be quite cumbersome defining more than 5 color/shader values…

but again, the model i use is for rapid prototyping and the colors never change. so once this is configured it is easily applied and re-applied to new imports.

if you look at the uv map in post #8 you can see it contains four different colors of the various layers on the printed circuit board. screen layer
2.solder mask over garolite layer
3.solder mask over copper clad layer copper clad layer (also sometimes gold plated)

to achieve the effect of that last render i simply used wave textures fed into the shades normal map.
it was the only way i could see to use this model as the mesh was inconsistent with the uv map and i really wanted to use shaders for this.
however displacement is nearly impossible unless someone knows how to fix that mesh a little so it could be subdivided???

so you use Rich multi color UV shadings

can you show us latest nodest set up you use

it looks good for a PCB!