Use proper depth linear value
This commit is contained in:
parent
f5a44c0a19
commit
b975b63eea
@ -17,5 +17,5 @@ void main(void)
|
||||
vec4 col = texture(tex, uv);
|
||||
#endif
|
||||
if (col.a < 0.5) discard;
|
||||
FragColor = vec4(gl_FragCoord.z);
|
||||
FragColor = vec4((2. * gl_FragCoord.z - 1.) / gl_FragCoord.w);
|
||||
}
|
||||
|
@ -2,5 +2,5 @@ out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
FragColor = vec4(gl_FragCoord.z);
|
||||
FragColor = vec4((2. * gl_FragCoord.z - 1.) / gl_FragCoord.w);
|
||||
}
|
||||
|
@ -12,5 +12,5 @@ void main(void)
|
||||
{
|
||||
vec4 col = texture(tex, uv);
|
||||
if (col.a < 0.5) discard;
|
||||
FragColor = vec4(gl_FragCoord.z);
|
||||
FragColor = vec4((2. * gl_FragCoord.z - 1.) / gl_FragCoord.w);
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ float getShadowFactor(vec3 pos, float bias, int index)
|
||||
);
|
||||
|
||||
vec4 shadowcoord = (ShadowViewProjMatrixes[index] * InverseViewMatrix * vec4(pos, 1.0));
|
||||
shadowcoord /= shadowcoord.w;
|
||||
shadowcoord.xy /= shadowcoord.w;
|
||||
vec2 shadowtexcoord = shadowcoord.xy * 0.5 + 0.5;
|
||||
// shadowcoord = (shadowcoord * 0.5) + vec3(0.5);
|
||||
|
||||
@ -55,7 +55,7 @@ float getShadowFactor(vec3 pos, float bias, int index)
|
||||
// return sum / 16.;
|
||||
|
||||
float z = texture(shadowtex, vec3(shadowtexcoord, float(index))).x;
|
||||
float d = .5 * shadowcoord.z + .5;
|
||||
float d = shadowcoord.z;
|
||||
return min(exp(1024 *(z - d)), 1.);
|
||||
}
|
||||
|
||||
|
@ -978,8 +978,6 @@ void IrrDriver::renderShadows()
|
||||
glDepthMask(GL_TRUE);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_BLEND);
|
||||
glCullFace(GL_FRONT);
|
||||
glEnable(GL_CULL_FACE);
|
||||
m_rtts->getShadowFBO().Bind();
|
||||
|
||||
glClearColor(1., 1., 1., 1.);
|
||||
@ -1022,9 +1020,6 @@ void IrrDriver::renderShadows()
|
||||
}
|
||||
}
|
||||
|
||||
glCullFace(GL_BACK);
|
||||
glDisable(GL_CULL_FACE);
|
||||
|
||||
m_post_processing->renderGaussian6BlurLayer(m_rtts->getShadowFBO());
|
||||
glBindTexture(GL_TEXTURE_2D_ARRAY, m_rtts->getShadowFBO().getRTT()[0]);
|
||||
glGenerateMipmap(GL_TEXTURE_2D_ARRAY);
|
||||
|
Loading…
Reference in New Issue
Block a user