Added non-linearization to get rid of fragments.
This commit is contained in:
parent
03e5fd19f5
commit
b4e92371db
@ -7,5 +7,10 @@ uniform float farPlane;
|
|||||||
out float gl_FragDepth;
|
out float gl_FragDepth;
|
||||||
|
|
||||||
void main() {
|
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;
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,8 @@ float samplePointShadow(samplerCubeShadow shadowMap, vec3 lightDirection) {
|
|||||||
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.005;
|
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) {
|
float distanceToBorder(vec2 vector) {
|
||||||
|
Loading…
Reference in New Issue
Block a user