From 791773fa9d8a9e353608bb778a1e0247940d91f9 Mon Sep 17 00:00:00 2001 From: Brian Semrau Date: Tue, 26 Oct 2021 16:19:47 -0400 Subject: [PATCH] Fix vulkan proximity fade Vulkan uses different normalized device coordinates than OpenGL. --- scene/resources/material.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index abb3381c4ee..267180973ff 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -1100,7 +1100,7 @@ void BaseMaterial3D::_update_shader() { if (proximity_fade_enabled) { code += " float depth_tex = textureLod(DEPTH_TEXTURE,SCREEN_UV,0.0).r;\n"; - code += " vec4 world_pos = INV_PROJECTION_MATRIX * vec4(SCREEN_UV*2.0-1.0,depth_tex*2.0-1.0,1.0);\n"; + code += " vec4 world_pos = INV_PROJECTION_MATRIX * vec4(SCREEN_UV*2.0-1.0,depth_tex,1.0);\n"; code += " world_pos.xyz/=world_pos.w;\n"; code += " ALPHA*=clamp(1.0-smoothstep(world_pos.z+proximity_fade_distance,world_pos.z,VERTEX.z),0.0,1.0);\n"; }