diff --git a/data/shaders/fs_deferred_lighting.glsl b/data/shaders/fs_deferred_lighting.glsl index 0cc8e32..229c5ee 100644 --- a/data/shaders/fs_deferred_lighting.glsl +++ b/data/shaders/fs_deferred_lighting.glsl @@ -28,10 +28,14 @@ float ShadowCalculationPCF(vec4 frag_pos_light_space, vec3 frag_normal_light_spa vec3 projected_coordinates = frag_pos_light_space.xyz / frag_pos_light_space.w; projected_coordinates = projected_coordinates * 0.5 + 0.5; + if (abs(projected_coordinates.z) > 1.0 ) { + return 1.0; + } + float current_depth = projected_coordinates.z; float bias = 0.00; - bias = max(0.01 * (1.0 - dot(frag_normal_light_space, uLightDirection)), uShadowBias); + bias = max(0.001 * (1.0 - dot(frag_normal_light_space, uLightDirection)), uShadowBias); float shadow = 0.0; vec2 texel_size = 1.0 / textureSize(uShadowMap, 0); diff --git a/src/modules/RenderModule.cc b/src/modules/RenderModule.cc index 869277c..f8fb28a 100644 --- a/src/modules/RenderModule.cc +++ b/src/modules/RenderModule.cc @@ -510,6 +510,7 @@ void Renderer::RenderGl() { // Shadow Map mLight.mShadowMapTarget.Bind(); + mLight.mPosition = mCamera.mEye; glViewport(0, 0, mLight.mShadowMapSize, mLight.mShadowMapSize); mLight.UpdateMatrices(); glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);