Browse Source

Fix missing shadows when sun tilt is zero

x2048 1 year ago
parent
commit
1de8a1e962

+ 1 - 1
client/shaders/nodes_shader/opengl_fragment.glsl

@@ -392,7 +392,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) {
 

+ 1 - 1
client/shaders/nodes_shader/opengl_vertex.glsl

@@ -241,7 +241,7 @@ void main(void)
 		float pFactor = getPerspectiveFactor(getRelativePosition(m_ShadowViewProj * mWorld * shadow_pos));
 		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 = 2.0 * pFactor * pFactor * sinLight * min(f_shadowfar, 500.0) /
 					xyPerspectiveBias1 / f_textureresolution;

+ 1 - 1
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) {
 

+ 1 - 1
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;