Jelajahi Sumber

Merge pull request #51433 from Calinou/spatialmaterial-improve-simple-parallax

Rémi Verschelde 3 tahun lalu
induk
melakukan
c3a6b0f418
1 mengubah file dengan 3 tambahan dan 1 penghapusan
  1. 3 1
      scene/resources/material.cpp

+ 3 - 1
scene/resources/material.cpp

@@ -776,7 +776,9 @@ void SpatialMaterial::_update_shader() {
 
 		} else {
 			code += "\t\tfloat depth = texture(texture_depth, base_uv).r;\n";
-			code += "\t\tvec2 ofs = base_uv - view_dir.xy / view_dir.z * (depth * depth_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 += "\t\tvec2 ofs = base_uv - view_dir.xy * depth * depth_scale;\n";
 		}
 
 		code += "\t\tbase_uv=ofs;\n";