diff --git a/data/shaders/instanced_shadowref.frag b/data/shaders/instanced_shadowref.frag index fc210c491..f303688b6 100644 --- a/data/shaders/instanced_shadowref.frag +++ b/data/shaders/instanced_shadowref.frag @@ -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); } diff --git a/data/shaders/shadow.frag b/data/shaders/shadow.frag index 1239ac3de..128b3e31c 100644 --- a/data/shaders/shadow.frag +++ b/data/shaders/shadow.frag @@ -2,5 +2,5 @@ out vec4 FragColor; void main() { - FragColor = vec4(gl_FragCoord.z); + FragColor = vec4((2. * gl_FragCoord.z - 1.) / gl_FragCoord.w); } diff --git a/data/shaders/shadowref.frag b/data/shaders/shadowref.frag index ea29aafec..ec6905c6d 100644 --- a/data/shaders/shadowref.frag +++ b/data/shaders/shadowref.frag @@ -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); } diff --git a/data/shaders/sunlightshadow.frag b/data/shaders/sunlightshadow.frag index 7ab1772ef..346f33f1c 100644 --- a/data/shaders/sunlightshadow.frag +++ b/data/shaders/sunlightshadow.frag @@ -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.); } diff --git a/src/graphics/render_geometry.cpp b/src/graphics/render_geometry.cpp index 33fe28409..13d2505c6 100644 --- a/src/graphics/render_geometry.cpp +++ b/src/graphics/render_geometry.cpp @@ -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);