Take eye offset into account for depth in StandardMaterial3D

(cherry picked from commit 581d081ded)
This commit is contained in:
Bastiaan Olij 2023-07-05 15:38:40 +10:00 committed by Yuri Sizov
parent da1e511f11
commit 89e64da028
1 changed files with 1 additions and 1 deletions

View File

@ -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";