Ver Fonte

Merge pull request #76240 from clayjohn/Light2D-artifacts

Clamp normal when calculating 2D lighting to avoid artifacts
Rémi Verschelde há 2 anos atrás
pai
commit
27253f3eb2

+ 1 - 1
drivers/gles3/shaders/canvas.glsl

@@ -589,7 +589,7 @@ void main() {
 		if (bool(read_draw_data_flags & FLAGS_FLIP_V)) {
 			normal.y = -normal.y;
 		}
-		normal.z = sqrt(1.0 - dot(normal.xy, normal.xy));
+		normal.z = sqrt(max(0.0, 1.0 - dot(normal.xy, normal.xy)));
 		normal_used = true;
 	} else {
 		normal = vec3(0.0, 0.0, 1.0);

+ 1 - 1
servers/rendering/renderer_rd/shaders/canvas.glsl

@@ -508,7 +508,7 @@ void main() {
 		if (bool(draw_data.flags & FLAGS_FLIP_V)) {
 			normal.y = -normal.y;
 		}
-		normal.z = sqrt(1.0 - dot(normal.xy, normal.xy));
+		normal.z = sqrt(max(0.0, 1.0 - dot(normal.xy, normal.xy)));
 		normal_used = true;
 	} else {
 		normal = vec3(0.0, 0.0, 1.0);