Displacement Using Color Values From A Texture Map

In this challenge we were asked to displace a polygonal object based on a specific color value from a texture map. The color value and texture map should be able to be assigned by the artist within the parameter interface of whatever 3D package the artist is using. The first thing was to break the texture map into its RGB componets. To do this, I defined the texture values within the shader using:

"color" = texture(texname[])

Where color is the variable name you would wamt to use (i.e. red, green, blue),texname is the string value within the parameters and the brackets would be where you would place the values for the 3 colors within the texture map (i.e. [0] = red channel, [1] = green channel, [2] = blue channel). With the separated values, we are able to then write a number of IF tests to discern what areas to "bump" and what areas not to "bump". From the code for this shader you can see that I have also IF tested for the value of white. Since white is composed of 100% of all three colors (RGB) it would also bump when a specific value is used. I tested the area for white by isolating all three 100% colors and telling the shader not to "bump" the area. I have set up the shader to only "bump based on the red value that is entered into the shader. Below are images showing what I got from using this shader.

value = 0

click to enlarge

value = .50

click to enlarge

value = 1

click to enlarge

This shows that with the red value set to 0 ( 0% red) everything is "bumped". Which means that if it has any red (even none) it will "bump". At .50 (50% red), you start to see that colors that have some red (i.e magenta) will "bump" but color like blue or teal (combination of blue and green) will not "bump" since it has less than 50% red. The last image shows that any color with a value of 1 (100% red) will "bump". In all three images I have white clamped to not "bumping" no matter what value red is set at.

As you can see from the images this is still has problems discerning some of the color values, especially within white, but overall I think that this seem to work well. This is also only being tested on an image that has high saturation values for all the colors within the texture map. To get a true idea of if this is working it would probably be best used on an image that has different saturation values along with different red values.

click for code