Tweaked shadow map to follow camera movement
parent
24516b592e
commit
75677a5b70
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue