I can simply force 0,1 values via the shader, but I'd like to understand what's going on rather than force my expectations onto things.
For completeness, the fragment shader follows.
#version 110
varying vec3 frag_Position;
varying vec3 frag_Normal;
varying vec3 frag_LightDirection;
varying vec4 frag_ShadowCoordinate;
uniform sampler2DShadow frag_ShadowMap;
void main()
{
vec3 E =-normalize(frag_Position);
vec3 L = normalize(frag_LightDirection);
vec3 H = normalize(E + L);
// Get shadow value
float shadow = shadow2DProj( frag_ShadowMap, frag_ShadowCoordinate ).x;
//if (shadow < 1.0) shadow = 0.0;
// Light properties
const vec3 light_ads = vec3( 0.0, 1.0, 0.0 );
// Material properties
const vec4 material_adss = vec4( 0.0, 0.5, 0.0, 0.0 );
// Light/Material interaction
const vec3 lightCoefficient = light_ads * material_adss.rgb;
vec3 ambientDiffuseSpecular = vec3( 0.0,
shadow * max(0.0, dot(frag_Normal, L)),
shadow == 0.0 ? 0.0 : pow( max(0.0, dot(frag_Normal, H)), material_adss.a ));
// Ambient, Diffuse, Specular contributions
float shade = dot(lightCoefficient, ambientDiffuseSpecular);
gl_FragColor = vec4( shade * gl_Color.rgb, 1.0 );
}
1 comment:
I think it depends on what you set the tex parameter GL_TEXTURE_COMPARE_MODE_ARB to for your depth texture. I'm investigating this myself right now...
Post a Comment