0

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?

skiwi
  • 66,971
  • 31
  • 131
  • 216
  • Why are you grayscaling for the shadow? I simply test if the shadow result is <= ambient power and if it is I set the colour to ambientcolour + ambientpower and omit diffuse/specular altogether. – Rebirth Feb 07 '14 at 16:09
  • @Rebirth Ambient need not be a gray scale, or does it? – skiwi Feb 07 '14 at 16:51

0 Answers0