I am looking for a description of how shadow should be represented in the Phong lighting model. You can take a look at Phong shading here: http://en.wikipedia.org/wiki/Phong_shading
I think quite some people are, maybe unknowingly, familiar with it.
So onto the question: I have implemented shadow mapping in my graphics program, and now I am wondering how to apply shadow, I have the following in my fragment shader:
vec3 rgb_to_grayscale_luminosity(vec3 color) {
float value = color.r * 0.21 + color.g * 0.71 + color.b * 0.07;
return vec3(value);
}
void main(void) {
...
//apply shadow and write color
float shadow_value = textureProj(shadow_tex, fs_in.shadow_coord);
if (shadow_value < 0.9999) {
//in shadow
color = vec4(rgb_to_grayscale_luminosity(ambient + diffuse), 1.0);
}
else {
//no shadow
color = vec4(ambient + diffuse + specular, 1.0);
}
}
I am adhering to the following constraints currently:
- Shadows are the original color converted to a grayscale.
- Shadows do not have a specular component.
I am firstly wondering if this is a correct model, and secondly one specific question:
Should diffuse lighting be accounted for in the shadows, or not?