1
0
mirror of https://github.com/LearnOpenGL-CN/LearnOpenGL-CN.git synced 2025-08-23 04:35:28 +08:00
This commit is contained in:
Krasjet
2019-02-03 15:19:50 -05:00
parent 9fef24af66
commit 8013890ec6
5 changed files with 6 additions and 9 deletions

View File

@@ -449,7 +449,7 @@ glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, borderColor);
当一个点比光的远平面还要远时它的投影坐标的z坐标大于1.0。这种情况下GL_CLAMP_TO_BORDER环绕方式不起作用因为我们把坐标的z元素和深度贴图的值进行了对比它总是为大于1.0的z返回true。
解决这个问题也很简单,我们简单的强制把shadow的值设为0.0不管投影向量的z坐标是否大于1.0
解决这个问题也很简单,只要投影向量的z坐标大于1.0,我们就把shadow的值强制设为0.0
```c++
float ShadowCalculation(vec4 fragPosLightSpace)

View File

@@ -193,10 +193,10 @@ void main()
```c++
#version 330 core
in vec4 FragPos;
uniform vec3 lightPos;
uniform float far_plane;
void main()
{
// get distance between fragment and light source
@@ -205,7 +205,7 @@ void main()
// map to [0;1] range by dividing by far_plane
lightDistance = lightDistance / far_plane;
// Write this as modified depth
// write this as modified depth
gl_FragDepth = lightDistance;
}
```