Skip to content

Commit

Permalink
Merge pull request #79049 from BastiaanOlij/fix_stereo_depth_paralax
Browse files Browse the repository at this point in the history
Take eye offset into account for depth in StandardMaterial3D
  • Loading branch information
akien-mga committed Jul 7, 2023
2 parents 8e5a01f + 581d081 commit 5d23586
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion scene/resources/material.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,7 @@ void BaseMaterial3D::_update_shader() {

if (!RenderingServer::get_singleton()->is_low_end() && features[FEATURE_HEIGHT_MAPPING] && !flags[FLAG_UV1_USE_TRIPLANAR]) { //heightmap not supported with triplanar
code += " {\n";
code += " vec3 view_dir = normalize(normalize(-VERTEX)*mat3(TANGENT*heightmap_flip.x,-BINORMAL*heightmap_flip.y,NORMAL));\n"; // binormal is negative due to mikktspace, flip 'unflips' it ;-)
code += " vec3 view_dir = normalize(normalize(-VERTEX + EYE_OFFSET) * mat3(TANGENT * heightmap_flip.x, -BINORMAL * heightmap_flip.y, NORMAL));\n"; // binormal is negative due to mikktspace, flip 'unflips' it ;-)

if (deep_parallax) {
code += " float num_layers = mix(float(heightmap_max_layers),float(heightmap_min_layers), abs(dot(vec3(0.0, 0.0, 1.0), view_dir)));\n";
Expand Down

0 comments on commit 5d23586

Please sign in to comment.