summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl11
-rw-r--r--servers/rendering/renderer_rd/shaders/scene_forward_mobile.glsl11
2 files changed, 14 insertions, 8 deletions
diff --git a/servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl b/servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl
index 9b72ccc87d..608b76b108 100644
--- a/servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl
+++ b/servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl
@@ -251,7 +251,9 @@ void main() {
vertex = (world_matrix * vec4(vertex, 1.0)).xyz;
+#ifdef NORMAL_USED
normal = world_normal_matrix * normal;
+#endif
#if defined(TANGENT_USED) || defined(NORMAL_MAP_USED) || defined(LIGHT_ANISOTROPY_USED)
@@ -290,12 +292,13 @@ void main() {
#if !defined(SKIP_TRANSFORM_USED) && defined(VERTEX_WORLD_COORDS_USED)
vertex = (scene_data.inv_camera_matrix * vec4(vertex, 1.0)).xyz;
- normal = mat3(scene_data.inverse_normal_matrix) * normal;
+#ifdef NORMAL_USED
+ normal = (scene_data.inv_camera_matrix * vec4(normal, 0.0)).xyz;
+#endif
#if defined(TANGENT_USED) || defined(NORMAL_MAP_USED) || defined(LIGHT_ANISOTROPY_USED)
-
- binormal = mat3(scene_data.camera_inverse_binormal_matrix) * binormal;
- tangent = mat3(scene_data.camera_inverse_tangent_matrix) * tangent;
+ binormal = (scene_data.inv_camera_matrix * vec4(binormal, 0.0)).xyz;
+ tangent = (scene_data.inv_camera_matrix * vec4(tangent, 0.0)).xyz;
#endif
#endif
diff --git a/servers/rendering/renderer_rd/shaders/scene_forward_mobile.glsl b/servers/rendering/renderer_rd/shaders/scene_forward_mobile.glsl
index e92fbecfd0..9e3732fd2b 100644
--- a/servers/rendering/renderer_rd/shaders/scene_forward_mobile.glsl
+++ b/servers/rendering/renderer_rd/shaders/scene_forward_mobile.glsl
@@ -261,7 +261,9 @@ void main() {
vertex = (world_matrix * vec4(vertex, 1.0)).xyz;
+#ifdef NORMAL_USED
normal = world_normal_matrix * normal;
+#endif
#if defined(TANGENT_USED) || defined(NORMAL_MAP_USED) || defined(LIGHT_ANISOTROPY_USED)
@@ -302,12 +304,13 @@ void main() {
#if !defined(SKIP_TRANSFORM_USED) && defined(VERTEX_WORLD_COORDS_USED)
vertex = (scene_data.inv_camera_matrix * vec4(vertex, 1.0)).xyz;
- normal = mat3(scene_data.inverse_normal_matrix) * normal;
+#ifdef NORMAL_USED
+ normal = (scene_data.inv_camera_matrix * vec4(normal, 0.0)).xyz;
+#endif
#if defined(TANGENT_USED) || defined(NORMAL_MAP_USED) || defined(LIGHT_ANISOTROPY_USED)
-
- binormal = mat3(scene_data.camera_inverse_binormal_matrix) * binormal;
- tangent = mat3(scene_data.camera_inverse_tangent_matrix) * tangent;
+ binormal = (scene_data.inv_camera_matrix * vec4(binormal, 0.0)).xyz;
+ tangent = (scene_data.inv_camera_matrix * vec4(tangent, 0.0)).xyz;
#endif
#endif