Added non-linearization to get rid of fragments.

This commit is contained in:
Faerbit 2015-02-05 13:19:51 +01:00
parent 03e5fd19f5
commit b4e92371db
2 changed files with 8 additions and 2 deletions

View File

@ -7,5 +7,10 @@ uniform float farPlane;
out float gl_FragDepth;
void main() {
gl_FragDepth = length(fragPosition)/farPlane;
float nearPlane = 0.1;
float A = -(farPlane+nearPlane)/(farPlane-nearPlane);
float B = -2*(farPlane*nearPlane)/(farPlane - nearPlane);
float value = 0.5*(-A*length(fragPosition) + B)/length(fragPosition) + 0.5;
gl_FragDepth = value;
//gl_FragDepth = length(fragPosition)/farPlane;
}

View File

@ -71,7 +71,8 @@ float samplePointShadow(samplerCubeShadow shadowMap, vec3 lightDirection) {
float B = -2*(farPlane*nearPlane)/(farPlane - nearPlane);
float compValue = 0.5*(-A*length(lightDirection) + B)/length(lightDirection) + 0.5;
float bias = 0.005;
return texture(shadowMap, vec4(lightDirection , length(lightDirection)/farPlane - bias));
//return texture(shadowMap, vec4(lightDirection , length(lightDirection)/farPlane - bias));
return texture(shadowMap, vec4(lightDirection , compValue - bias));
}
float distanceToBorder(vec2 vector) {