diff options
author | Juan Linietsky <reduzio@gmail.com> | 2021-09-09 17:24:07 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-09 17:24:07 -0300 |
commit | 5e585eafe63cb37e35276857aa87c37317f37646 (patch) | |
tree | d8d27e2e26dddba52ab430a1d30fa5b098771aa4 | |
parent | 3c554f09eab5989ab775704d5722d528ffc71ad5 (diff) | |
parent | e47d0e021a4398dfa35e41108597dd784689741c (diff) |
Merge pull request #50383 from Calinou/standardmaterial3d-improve-simple-parallax
Improve the appearance of simple parallax in StandardMaterial3D
-rw-r--r-- | scene/resources/material.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index 1d2a2ef26c..77a68151c4 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -963,7 +963,9 @@ void BaseMaterial3D::_update_shader() { } else { code += " float depth = 1.0 - texture(texture_heightmap, base_uv).r;\n"; } - code += " vec2 ofs = base_uv - view_dir.xy / view_dir.z * (depth * heightmap_scale);\n"; + // Use offset limiting to improve the appearance of non-deep parallax. + // This reduces the impression of depth, but avoids visible warping in the distance. + code += " vec2 ofs = base_uv - view_dir.xy * depth * heightmap_scale;\n"; } code += " base_uv=ofs;\n"; |