summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Semrau <brian.semrau@gmail.com>2021-10-26 16:19:47 -0400
committerBrian Semrau <brian.semrau@gmail.com>2021-10-26 16:19:47 -0400
commit791773fa9d8a9e353608bb778a1e0247940d91f9 (patch)
tree9a4233113054327ad18ed1ff270fce6668a41730
parent8c162f4a7ba0f542cd7e9fbbe30f004504cc0809 (diff)
Fix vulkan proximity fade
Vulkan uses different normalized device coordinates than OpenGL.
-rw-r--r--scene/resources/material.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index abb3381c4e..267180973f 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";
}