summaryrefslogtreecommitdiff
path: root/scene/resources/material.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/resources/material.cpp')
-rw-r--r--scene/resources/material.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index 896a33e02e..77a68151c4 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -31,6 +31,7 @@
#include "material.h"
#include "core/config/engine.h"
+#include "core/version.h"
#ifdef TOOLS_ENABLED
#include "editor/editor_settings.h"
@@ -469,7 +470,12 @@ void BaseMaterial3D::_update_shader() {
//must create a shader!
- String code = "shader_type spatial;\nrender_mode ";
+ // Add a comment to describe the shader origin (useful when converting to ShaderMaterial).
+ String code = vformat(
+ "// NOTE: Shader automatically converted from " VERSION_NAME " " VERSION_FULL_CONFIG "'s %s.\n\n",
+ orm ? "ORMMaterial3D" : "StandardMaterial3D");
+
+ code += "shader_type spatial;\nrender_mode ";
switch (blend_mode) {
case BLEND_MODE_MIX:
code += "blend_mix";
@@ -957,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";