Skip to content

Commit

Permalink
Merge pull request #50383 from Calinou/standardmaterial3d-improve-sim…
Browse files Browse the repository at this point in the history
…ple-parallax

Improve the appearance of simple parallax in StandardMaterial3D
  • Loading branch information
reduz authored Sep 9, 2021
2 parents 3c554f0 + e47d0e0 commit 5e585ea
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion scene/resources/material.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit 5e585ea

Please sign in to comment.