Improve the appearance of simple parallax in SpatialMaterial

This uses offset limiting to avoid distortion in the distance,
and makes simple (non-deep) parallax more usable overall.
This commit is contained in:
Hugo Locurcio 2021-08-09 15:11:36 +02:00
parent a05aefb74b
commit cc2b6acbd2
No known key found for this signature in database
GPG key ID: 39E8F8BE30B0A49C

View file

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