7

Red & Green: Perfect channel separators

I'd like to do three things:

  1. Make the Red area glossy
  2. Make the Green area roughly diffuse
  3. Make the Green area appear higher than/on top of the red area (bump height).

Basically I'm looking for a procedural/node technique I can use to treat areas separated by color (or alpha). In the pictured set-up I'm using red and green (as I thought splitting colors to RGB could be a solution), but I'd like the solution to be used with any colors required.

Any clues would be gratefully appreciated :)

OroNZ
  • 1,207
  • 3
  • 14
  • 27

2 Answers2

10

With two different known colours you can use the Separate RGB node:

enter image description here

The R output of the node already give us a map of the red areas (full white=1)

enter image description here

You can use the mask both in a Bump Node and in a Mix Shader node.


If you would like to implement a similar process with every possible colour you can set up a Node tree capable of recognize where a given color is.

enter image description here

Basically you have to mask where the the color that correspond to the shader to mix is on the map by masking individually each component. Starting from the HUE values we check with math nodes where the subtraction gives almost = 0.

enter image description here

Than we can copy this node also for the Saturation and Value...ehm...values! By multiplying their output we are running an Logical AND operation, so at the and we'll have only the places where all three parameters have the same values.

enter image description here


By making a whole group of these operations you'll be able to match each colour to a shader simply by giving the color to pick:

enter image description here

Here's an example of usage with files made by an external application such as the SciFi Helmet by Michael Pavlovic. You can pick the colour from the Colour Id mask directly from the render preview.

enter image description here

Carlo
  • 24,826
  • 2
  • 49
  • 92
  • ...It's going to take me weeks to get my head around that Blend file, but WOW! The power! Thanks Carlo! – OroNZ Sep 05 '15 at 10:27
  • I've written a more in depth explanation at: http://carlobergonziniplayground.tumblr.com/post/128405180147/use-color-id-masks-in-blender-cycles (still working on it) – Carlo Sep 05 '15 at 14:46
  • Hi can we make this work with soft edges ? – Fox Apr 03 '19 at 00:49
  • the concept is amazing but for hard sodt edges, it dont work at all https://blender.stackexchange.com/posts/136035/edit – Fox Apr 03 '19 at 08:43
4

Here's a simple set up to do what you asked for:

Nodes

The noise texture is converted to greyscale (a value between 0.0 and 1.0). Then we test to see if the greyscale value is greater than 0.5. (If it's < 0.5 then we get a value of 0.0. If it's greater than 0.5 we get a value of 1.0).

That value of 0.0 or 1.0 can then be used as the factor in a mix shader, and also directly for the surface displacement. (You could add a multiply node in there if necessary).

(I believe the RGB to BW node happens implicitly - as in your set up above, so you could skip it.)

user673679
  • 368
  • 1
  • 12