From af1d81d95a9bced2e4c05488d8117963d1620863 Mon Sep 17 00:00:00 2001 From: clayjohn Date: Thu, 5 Oct 2023 22:05:44 -0600 Subject: [PATCH] Only perform modelview transform on tangent and binormal when vertex shader is in local space --- drivers/gles3/shaders/scene.glsl | 3 +-- .../shaders/forward_clustered/scene_forward_clustered.glsl | 3 +-- .../shaders/forward_mobile/scene_forward_mobile.glsl | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl index c98b5f3ed7e..5a1c6c15218 100644 --- a/drivers/gles3/shaders/scene.glsl +++ b/drivers/gles3/shaders/scene.glsl @@ -417,13 +417,12 @@ void main() { normal = modelview_normal * normal; #endif -#endif - #if defined(TANGENT_USED) || defined(NORMAL_MAP_USED) || defined(LIGHT_ANISOTROPY_USED) binormal = modelview_normal * binormal; tangent = modelview_normal * tangent; #endif +#endif // !defined(SKIP_TRANSFORM_USED) && !defined(VERTEX_WORLD_COORDS_USED) // Using world coordinates #if !defined(SKIP_TRANSFORM_USED) && defined(VERTEX_WORLD_COORDS_USED) diff --git a/servers/rendering/renderer_rd/shaders/forward_clustered/scene_forward_clustered.glsl b/servers/rendering/renderer_rd/shaders/forward_clustered/scene_forward_clustered.glsl index 56e466ba987..8e6db7583ea 100644 --- a/servers/rendering/renderer_rd/shaders/forward_clustered/scene_forward_clustered.glsl +++ b/servers/rendering/renderer_rd/shaders/forward_clustered/scene_forward_clustered.glsl @@ -411,13 +411,12 @@ void vertex_shader(vec3 vertex_input, normal = modelview_normal * normal; #endif -#endif - #ifdef TANGENT_USED binormal = modelview_normal * binormal; tangent = modelview_normal * tangent; #endif +#endif // !defined(SKIP_TRANSFORM_USED) && !defined(VERTEX_WORLD_COORDS_USED) //using world coordinates #if !defined(SKIP_TRANSFORM_USED) && defined(VERTEX_WORLD_COORDS_USED) diff --git a/servers/rendering/renderer_rd/shaders/forward_mobile/scene_forward_mobile.glsl b/servers/rendering/renderer_rd/shaders/forward_mobile/scene_forward_mobile.glsl index ade40cbf7a6..a9e9a617d65 100644 --- a/servers/rendering/renderer_rd/shaders/forward_mobile/scene_forward_mobile.glsl +++ b/servers/rendering/renderer_rd/shaders/forward_mobile/scene_forward_mobile.glsl @@ -408,13 +408,12 @@ void main() { normal = modelview_normal * normal; #endif -#endif - #if defined(TANGENT_USED) || defined(NORMAL_MAP_USED) || defined(LIGHT_ANISOTROPY_USED) binormal = modelview_normal * binormal; tangent = modelview_normal * tangent; #endif +#endif // !defined(SKIP_TRANSFORM_USED) && !defined(VERTEX_WORLD_COORDS_USED) //using world coordinates #if !defined(SKIP_TRANSFORM_USED) && defined(VERTEX_WORLD_COORDS_USED)