I have looked at two different vertex shaders that calculate luminance and both use a "magic" vector that I'm not sure the meaning of the the actual values. For instance:
const mediump vec3 Perception = vec3(0.299, 0.587, 0.114);
void main(void)
{
mediump vec3 color = texture2D(Sampler, TextureCoord).xyz;
mediump float luminance = dot(Perception, color);
gl_FragColor = (luminance > Threshold) ? vec4(color, 1) : vec4(0);
}
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?