Corrected bias calculation for point light shadows.

This commit is contained in:
Fabian Klemp 2015-03-09 16:41:12 +01:00
parent 8dab0b313d
commit 3c3ba3e524

View File

@ -132,8 +132,8 @@ float samplePointShadow(samplerCubeShadow shadowMap, vec3 lightDirection) {
float A = -(farPlane+nearPlane)/(farPlane-nearPlane); float A = -(farPlane+nearPlane)/(farPlane-nearPlane);
float B = -2*(farPlane*nearPlane)/(farPlane - nearPlane); float B = -2*(farPlane*nearPlane)/(farPlane - nearPlane);
float compValue = 0.5*(-A*length(lightDirection) + B)/length(lightDirection) + 0.5; float compValue = 0.5*(-A*length(lightDirection) + B)/length(lightDirection) + 0.5;
float bias = 0.001*tan(acos(clamp(dot(vNormal, -directionalLightVector), 0.0, 1.0))); float bias = 0.001*tan(acos(clamp(dot(vNormal, lightDirection), 0.0, 1.0)));
bias = clamp(bias, 0.0, 0.01); bias = clamp(bias, 0.0, 0.001);
return texture(shadowMap, vec4(lightDirection , compValue - bias)); return texture(shadowMap, vec4(lightDirection , compValue - bias));
} }