Skip to content

Commit

Permalink
Merge pull request #76240 from clayjohn/Light2D-artifacts
Browse files Browse the repository at this point in the history
Clamp normal when calculating 2D lighting to avoid artifacts
  • Loading branch information
akien-mga committed Apr 19, 2023
2 parents c01b11e + ab603e3 commit 27253f3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion drivers/gles3/shaders/canvas.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion servers/rendering/renderer_rd/shaders/canvas.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 27253f3

Please sign in to comment.