summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorPatrick <patrick.exner1@web.de>2023-03-14 15:05:01 +0100
committerYuri Sizov <yuris@humnom.net>2023-03-27 17:31:54 +0200
commit9278da6f9b44be643db22edef39a3d93e126461a (patch)
treea1d7de516170bc6f122daf44ee1566fa5b8f5c1c /scene
parentb43f84780882358d451bece176de2c854f666f30 (diff)
Fix ndc calculation for LinearSceneDepth VS node in GLES3
(cherry picked from commit e3802d5b6f4413b80f9d3a7dce3e54b4e3d34d38)
Diffstat (limited to 'scene')
-rw-r--r--scene/resources/visual_shader_nodes.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/scene/resources/visual_shader_nodes.cpp b/scene/resources/visual_shader_nodes.cpp
index 9f5a64597a..7fdad8e930 100644
--- a/scene/resources/visual_shader_nodes.cpp
+++ b/scene/resources/visual_shader_nodes.cpp
@@ -1709,8 +1709,11 @@ String VisualShaderNodeLinearSceneDepth::generate_code(Shader::Mode p_mode, Visu
code += " {\n";
code += " float __log_depth = textureLod(" + make_unique_id(p_type, p_id, "depth_tex") + ", SCREEN_UV, 0.0).x;\n";
- code += " vec3 __depth_ndc = vec3(SCREEN_UV * 2.0 - 1.0, __log_depth);\n";
- code += " vec4 __depth_view = INV_PROJECTION_MATRIX * vec4(__depth_ndc, 1.0);\n";
+ if (!RenderingServer::get_singleton()->is_low_end()) {
+ code += " vec4 __depth_view = INV_PROJECTION_MATRIX * vec4(SCREEN_UV * 2.0 - 1.0, __log_depth, 1.0);\n";
+ } else {
+ code += " vec4 __depth_view = INV_PROJECTION_MATRIX * vec4(vec3(SCREEN_UV, __log_depth) * 2.0 - 1.0, 1.0);\n";
+ }
code += " __depth_view.xyz /= __depth_view.w;\n";
code += vformat(" %s = -__depth_view.z;\n", p_output_vars[0]);