What is the point of this hard-coded vector when calculating luminance in glow/bloom effects?
This was taken from the iPhone 3D programming book.
This perception vector is the magic vector I'm trying to figure out. I added the rgb/xyz values and the add to 1.
I saw another example that used vec3( 0.2125, 0.7154, 0.0721), which also adds to 1.
Can someone explain how one comes up with these values and what they really mean?
When you want to obtain the relative luminance from a RGB color, you are mapping the three values to a single grayscale one. This is achieved by multiplying each of the components by a constant and adding them together, so the final result is in the 0-1 range. That's why the two vectors you found so far are added to 1, because applying the operation to pure white (vec3(1, 1, 1)) will return 1.
The logic behind having a higher green and red components is because the photoreceptor cones in your eye's retina are more sensitive to these components than blue; a little variation of green color (the most sensitive one) can dramatically change the perception of the total luminance perceived by your eye.
And I would stick with the vec3(0.2126, 0.7152, 0.0722) values, since they are the ones used for sRGB color spaces. The first example you posted corresponds to the YCbCr color encoding, and it can cause incorrect results in your calculations.
Not the answer you're looking for? Browse other questions tagged mathematics shaders or ask your own question.
What are the steps taken by this GLSL code?
What is the edge glow shading technique used in Super Mario called?
What causes this InvalidOperationException when drawing primitives?
What is the mathematical explanation behind this implementation of simulating eyeballs roll in eyes?
Work out the point on an ellipse given centre, radius, and direction vector?
What is the meaning of this line algorithm?
What are the meanings of theta and gamma in this equation?