diff options
author | João Pedro Braz <brazjoaopedro@ymail.com> | 2023-03-29 10:17:15 -0300 |
---|---|---|
committer | Yuri Sizov <yuris@humnom.net> | 2023-04-24 16:52:24 +0200 |
commit | 1a85f6398fe62f8879675ace2401bb7d1a4ff4c5 (patch) | |
tree | 9b119be904481367b6e15b8cb52c380dc6a4f81a /servers/rendering/renderer_rd | |
parent | ad582cf0b163a8c15ba6a372ee76e0133213976c (diff) |
Use MODELVIEW_MATRIX for vertex transform when double precision is enabled
This commit updates the double precision vertex transform code from
using the MODEL_MATRIX to now use the MODELVIEW_MATRIX instead.
This can be made possible by transforming the MODELVIEW_MATRIX
back into model space (ie, same space as the MODEL_MATRIX) and then using it as if it were the MODEL_MATRIX.
With this in place we now properly handle VERTEX transformations that
a Material Shader might do, such as billboard-ing.
(cherry picked from commit 63c6f0b93ccc0f016b6b6ff7833c31371059a782)
Diffstat (limited to 'servers/rendering/renderer_rd')
-rw-r--r-- | servers/rendering/renderer_rd/shaders/forward_clustered/scene_forward_clustered.glsl | 2 | ||||
-rw-r--r-- | servers/rendering/renderer_rd/shaders/forward_mobile/scene_forward_mobile.glsl | 4 |
2 files changed, 2 insertions, 4 deletions
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 c8ad1f0312..0098b13d5b 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 @@ -360,7 +360,7 @@ void vertex_shader(in uint instance_index, in bool is_multimesh, in uint multime vertex = mat3(matrix) * vertex; model_origin = double_add_vec3(model_origin, model_precision, matrix[3].xyz, vec3(0.0), model_precision); } - vertex = mat3(model_matrix) * vertex; + vertex = mat3(inv_view_matrix * modelview) * vertex; vec3 temp_precision; // Will be ignored. vertex += double_add_vec3(model_origin, model_precision, scene_data.inv_view_matrix[3].xyz, view_precision, temp_precision); vertex = mat3(scene_data.view_matrix) * vertex; 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 a8b28bbd4f..80f05e7121 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 @@ -347,8 +347,6 @@ void main() { #CODE : VERTEX } - /* output */ - // using local coordinates (default) #if !defined(SKIP_TRANSFORM_USED) && !defined(VERTEX_WORLD_COORDS_USED) @@ -361,7 +359,7 @@ void main() { vertex = mat3(matrix) * vertex; model_origin = double_add_vec3(model_origin, model_precision, matrix[3].xyz, vec3(0.0), model_precision); } - vertex = mat3(model_matrix) * vertex; + vertex = mat3(inv_view_matrix * modelview) * vertex; vec3 temp_precision; vertex += double_add_vec3(model_origin, model_precision, scene_data.inv_view_matrix[3].xyz, view_precision, temp_precision); vertex = mat3(scene_data.view_matrix) * vertex; |