From 5162021d762610126b5147ca0aa1f577e6c3a979 Mon Sep 17 00:00:00 2001 From: nonunknown Date: Sun, 10 Oct 2021 14:03:38 -0300 Subject: [PATCH 1/2] add inverted normals when flipped scale --- scene/resources/material.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index abb3381c4ee4..95ab1155c3a2 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -773,6 +773,9 @@ void BaseMaterial3D::_update_shader() { if (!flags[FLAG_UV1_USE_TRIPLANAR]) { code += " UV=UV*uv1_scale.xy+uv1_offset.xy;\n"; + code += " if (determinant(mat3(WORLD_MATRIX)) < 0.0) {"; + code += " NORMAL = -NORMAL;" + code += " }"; } switch (billboard_mode) { From ff169075d7500d941e76647515811d49664cde34 Mon Sep 17 00:00:00 2001 From: Non <58845030+nonunknown@users.noreply.github.com> Date: Sun, 10 Oct 2021 14:08:36 -0300 Subject: [PATCH 2/2] add missing semicolon --- scene/resources/material.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index 95ab1155c3a2..2a72913515d2 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -774,7 +774,7 @@ void BaseMaterial3D::_update_shader() { if (!flags[FLAG_UV1_USE_TRIPLANAR]) { code += " UV=UV*uv1_scale.xy+uv1_offset.xy;\n"; code += " if (determinant(mat3(WORLD_MATRIX)) < 0.0) {"; - code += " NORMAL = -NORMAL;" + code += " NORMAL = -NORMAL;"; code += " }"; }