diff options
author | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2021-07-12 00:44:24 +0200 |
---|---|---|
committer | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2021-08-09 15:10:39 +0200 |
commit | e47d0e021a4398dfa35e41108597dd784689741c (patch) | |
tree | ce86555888f076069daed927871286e78345b8ae /scene | |
parent | 90870fd48f0071d3563d73817cbb5ee793607c77 (diff) |
Improve the appearance of simple parallax in StandardMaterial3D
This uses offset limiting to avoid distortion in the distance,
and makes simple (non-deep) parallax more usable overall.
Diffstat (limited to 'scene')
-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 08f7274ff6..74410f1103 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -957,7 +957,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"; |