Node question(color to value)

When working with nodes I know that you can always plug a rgb color output to a value input. But a color value is supposed to be a vector that consists of three values so I don’t understand how it is possible to connect these three values to just one value? For example here: the density is one value that you can change but it’s possible to multiply the color with the value and just plug it into the density

Bild

Converting a color to a value like this will “squish” the color down to one color:



What’s interesting, and you can easily verify this- that gray is not the same as the separated X, Y, or Z, Hue, Saturation, or Value, or R, G, or B. You lose a lot of color information this way, if you have an RGB color. If you’re working with shades of gray, like you are in that color ramp, you lose no color information. This leads to believe that the resulting value is some normalization of Hue, Saturation, and Lightness

1 Like

Basically, it just converts the RGB to grayscale (grayscale is just one value). So it averages out each value in the 3-vector to one value. And of course if the color is already grayscale then nothing changes when Blender converts the RGB values into an average single value.


2 Likes

Hey, just to add some information to that subject, that seem simple …

The conversion of RGB to BW that append is based on lightness.
A 100% green color is brighter than a 100% blue, yet they are both 100% …
The RGB to BW take that into account.
And this conversion append every time you go from color to value in every nodes.
Unlike regular vector ( ex : 3D coord) when transformed to a single value, it’s a simple average of the X,Y,Z values.
So (1,0,0) to a single value is similar to (0,1,0) and equal to 0.333, but that’s different when dealing with colors.

Taken from the web :

The RGB values are converted to grayscale using the NTSC formula:
0.299 ∙ Red + 0.587 ∙ Green + 0.114 ∙ Blue.
This formula closely represents the average person’s relative perception of the brightness of red, green, and blue light.

4 Likes

A slight correction. :wink:

The values used to be based off of NTSC.

The current weighting values are based on BT-709.

0.2126(R) + 0.7152(G) + 0.0722(B)

https://developer.blender.org/diffusion/B/browse/master/source/blender/blenlib/BLI_math_color.h;ccb4e298735f066f9e9074d88320001ded6b1918$159?as=source&blame=off

2 Likes

Great ! That was picked in a hurry :smiley: ! Wasn’t sure of the exact formula, and indeed it wasn’t the good one !
Thanks for providing the right numbers !