diff options
| author | x2048 <codeforsmile@gmail.com> | 2023-03-11 13:49:40 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-11 13:49:40 +0100 |
| commit | 1de8a1e962098b94154111c7aafe18c4aab74fc9 (patch) | |
| tree | a63ae3f1b81d691b71fb73f4f61f2b9302351858 /client/shaders/object_shader | |
| parent | ad41d0af9d80568e50aac2c9512dcb8ca4f10060 (diff) | |
| download | minetest-1de8a1e962098b94154111c7aafe18c4aab74fc9.tar.xz | |
Fix missing shadows when sun tilt is zero
Diffstat (limited to 'client/shaders/object_shader')
| -rw-r--r-- | client/shaders/object_shader/opengl_fragment.glsl | 2 | ||||
| -rw-r--r-- | client/shaders/object_shader/opengl_vertex.glsl | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/client/shaders/object_shader/opengl_fragment.glsl b/client/shaders/object_shader/opengl_fragment.glsl index 662d0c865..4e80e7fbc 100644 --- a/client/shaders/object_shader/opengl_fragment.glsl +++ b/client/shaders/object_shader/opengl_fragment.glsl @@ -393,7 +393,7 @@ void main(void) float distance_rate = (1.0 - pow(clamp(2.0 * length(posLightSpace.xy - 0.5),0.0,1.0), 10.0)); if (max(abs(posLightSpace.x - 0.5), abs(posLightSpace.y - 0.5)) > 0.5) distance_rate = 0.0; - float f_adj_shadow_strength = max(adj_shadow_strength-mtsmoothstep(0.9,1.1, posLightSpace.z),0.0); + float f_adj_shadow_strength = max(adj_shadow_strength - mtsmoothstep(0.9, 1.1, posLightSpace.z),0.0); if (distance_rate > 1e-7) { diff --git a/client/shaders/object_shader/opengl_vertex.glsl b/client/shaders/object_shader/opengl_vertex.glsl index dc9c70cdf..4a28ff714 100644 --- a/client/shaders/object_shader/opengl_vertex.glsl +++ b/client/shaders/object_shader/opengl_vertex.glsl @@ -146,7 +146,7 @@ void main(void) float pFactor = getPerspectiveFactor(getRelativePosition(m_ShadowViewProj * mWorld * inVertexPosition)); if (f_normal_length > 0.0) { nNormal = normalize(vNormal); - cosLight = dot(nNormal, -v_LightDirection); + cosLight = max(1e-5, dot(nNormal, -v_LightDirection)); float sinLight = pow(1 - pow(cosLight, 2.0), 0.5); normalOffsetScale = 0.1 * pFactor * pFactor * sinLight * min(f_shadowfar, 500.0) / xyPerspectiveBias1 / f_textureresolution; |
