Color
Math of Color
There are a lots of calculation related on color in Shader, here is some tips.
Calculation
If the color is in grey tone, value of RGB is same, splite it and use r channel instead of color.
Color is a float3, 3 floats. Multipling a color will produce 4 calculations. If the color is in grey tone, use single channel will produce only 1 calculation.
Color to Brightness (luminance)
Brightness of color is NOT average of RGB value!
Formula:
brightness = r * 0.2126 + g * 0.7152 + b * 0.0722
This is based on the luminance coefficients defined by the ITU-R BT.709 standard, which reflects how the human eye perceives brightness for red, green, and blue components. The weights (0.2126
, 0.7152
, 0.0722
) correspond to the human eye's sensitivity to these color channels:
Red (r): 0.2126
Green (g): 0.7152
Blue (b): 0.0722
These weights emphasize green (the human eye is most sensitive to green light) while de-emphasizing blue and red.
If a grey tone color is needed, apply the brightness value to all channel of color.
Last updated