diff options
author | Yuri Rubinsky <chaosus89@gmail.com> | 2022-08-31 23:01:11 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-31 23:01:11 +0300 |
commit | a5db03efa724b8910281d73576d31cc662b8cc13 (patch) | |
tree | a4874c097f1f934d0aca23919a55d906ce9542f7 | |
parent | 736632ee7ed00a3474448cfd227f696f82905ac7 (diff) | |
parent | 323ff657c002c9b453f0598648c8a15c90ab93ba (diff) |
Merge pull request #65160 from paddy-exe/fix-linear-depth-gles
-rw-r--r-- | scene/resources/visual_shader_nodes.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/scene/resources/visual_shader_nodes.cpp b/scene/resources/visual_shader_nodes.cpp index 3b2b58516d..a968aebdaa 100644 --- a/scene/resources/visual_shader_nodes.cpp +++ b/scene/resources/visual_shader_nodes.cpp @@ -7247,7 +7247,11 @@ String VisualShaderNodeProximityFade::generate_code(Shader::Mode p_mode, VisualS String proximity_fade_distance = vformat("%s", p_input_vars[0]); code += " float __depth_tex = textureLod(DEPTH_TEXTURE, SCREEN_UV, 0.0).r;\n"; - code += " vec4 __depth_world_pos = INV_PROJECTION_MATRIX * vec4(SCREEN_UV * 2.0 - 1.0, __depth_tex, 1.0);\n"; + if (!RenderingServer::get_singleton()->is_low_end()) { + code += " vec4 __depth_world_pos = INV_PROJECTION_MATRIX * vec4(SCREEN_UV * 2.0 - 1.0, __depth_tex, 1.0);\n"; + } else { + code += " vec4 __depth_world_pos = INV_PROJECTION_MATRIX * vec4(vec3(SCREEN_UV, __depth_tex) * 2.0 - 1.0, 1.0);\n"; + } code += " __depth_world_pos.xyz /= __depth_world_pos.z;\n"; code += vformat(" %s = clamp(1.0 - smoothstep(__depth_world_pos.z + %s, __depth_world_pos.z, VERTEX.z), 0.0, 1.0);\n", p_output_vars[0], p_input_vars[0]); |