How does ColorRamp node work?

Maybe a strange question: How does ColorRamp node choose which color or which value (if it is connected to the Factor input socket of the next node) to pass to the next node? As far as I understand each pixel gets its own color/value, but I cannot figure out the logic of choosing it.

for bl for cycles

I assume it is more cycles here

it basically add bands of color
make a test with bands texture and ramp with a few colors bands and see what it gives


colorramptest1.blend (120 KB)

happy cl

RickyBlender, thank you for your explanations!

And what about this case:


The resulting color of the cube depends on both ColorRamp values: Color and Factor. I cannot figure out how and why it happens so.

normally for FAC you can use a Black and white coloramp

color ramp with colors I think will try to convert colors to value and may not give nice results!

unless you like what it gives

also here coloramp is not driving anything like a texture
so not certain what is coming out of that node !

happy cl

RickyBlender, thank you!

So, as I understood, ColorRamp is mostly used with textures.

you can put the colorramp like you did, and it mixes the colors. you dont see an effect in your case, since the colors you choose seem to have all the same value (in hsv mode). what goes into the factor of the mixshader node is the value of the colors in the colorramp, not the hue and not the saturation.

the colors of the entries for the node connection show, wether color is transfered or only value. grey socket means only value is coming in…

on another note. rather than using two diffuse and mix them via a mixshader, one would better use an mixcolor rgb node, put the yellow and blue in the two slots, and the colorrramp into the factor. then plug the misrgb into the color slot of a diffuse node and that to the output. the reason for doing this way is, that it eats less claculation resources. on small scenes it might be not noticable, but on large scenes your setup can increase rendertimes and ram usuage…

Doris, thank you for your reply and for your advice. I’ll take it into consideration.

In the example below the value of ColorRamp colors is 1 for all colors in it, but the output value changes somehow when the Fac value is being changed:



Any ideas?

You are using color output as a factor which is a value or grayscale input. Grayscale represented as RGB would mean that all channels have equal value


Top left shows the color ramp output converted to grayscale. It shows that the RGB values on it are 0.2139 in linear space. Using that value as a factor gives similar result as the color ramp connected to it (left material, left cube = right material, right cube).

Not sure how it actually handles the conversion to grayscale when a color output is connected to grayscale input but it still uses a value. Factor on the color ramp moves position on the slider. If you want a gradient, you have to input a gradient to the color ramp factor and it then maps the colors to those.


Cubes from left to right: input gradient, color ramp with black and white handles, colored handles (pure RGB)

Since the values in the gradient are offset by 0.2, there’s no value 0 which would map to pure red, so there isn’t one in the color ramp output.

what you have to understand is that colorramp node outputs whatever is in the ramp at a given value (0-1). If you don’t plug anything in the fac value it will take (your first screenshot) 0.500 as value and output the value in the colorramp at 0.500 (right the middle). Also in the other example you didn’t plug anything, the value is set to 0 so the color ramp will output the color at 0 in the Ramp, which is red, then the value (as in HSV) of this red is used to frive the mix.
was I clear?

easy way to change color to objects without duplicating materials, but just setting an ID to an object. Useful for variations when instancing many objects that require, well, variations. It should work with linked groups too

http://www.pasteall.org/pic/show.php?id=89565



If you are making procedural textures the colour ramp node is very useful, In the above examples the color ramp node and the height ramp are both tied together, So you can see the color change with the height of the texture.

JA12, thank you for your explanations. That the colors in ColorRamp are converted to grayscale ones explains the behaviour of the node.

Lsscpp, thank you for a quite useful recommendation. I’ll take it into consideration.

Joseph, thanks for your examples. I’ve not noticed Bump node before. It must be a good alternative to Displacement input of Material Output node.

The bump node is useful, With in reason. It does not change the geometry of object. But on the other hand. It is far more easy to render a normal map displacement then it is an extra few thousand more verts. But it is a powerful tool if used for what it is intended for