uniform sampler2DShadow ShadowMap;
uniform sampler2D TextureMap;

void main()
{
  // use manual comparision (GL_TEXTURE_COMPARE_MODE = GL_NONE)
//  float depth = shadow2DProj(ShadowMap, gl_TexCoord[1]).r;
//  float R = gl_TexCoord[1].z / gl_TexCoord[1].w;
//
//  float shadow = R < depth;

  // use texture comparision mode (GL_TEXTURE_COMPARE_MODE = GL_COMPARE_R_TO_TEXTURE)
  float shadow = shadow2DProj(ShadowMap, gl_TexCoord[1]).r;

  vec4 color = texture2D(TextureMap, gl_TexCoord[0].xy);

  gl_FragColor.rgb = vec3( color ) * mix(shadow, 0.8, 0.5);
  gl_FragColor.a = color.a;
}
