diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2024-06-12 10:00:23 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-06-12 10:00:23 +0200 |
commit | f1ac3e26cc280c2d6d982ba59f60f670cfd45fa8 (patch) | |
tree | acd918066d1324f821d611547a0777dfff3acf5e | |
parent | 292e50e17e3f6e2509d3178a00204f964a907460 (diff) | |
parent | 3b353075dc571e05bde1f4cdcb59d514a27b6cac (diff) | |
download | redot-engine-f1ac3e26cc280c2d6d982ba59f60f670cfd45fa8.tar.gz |
Merge pull request #83729 from Chaosus/vs_fix_texture_param
Add extra warning messages to `VisualShaderNodeTextureParameter`
-rw-r--r-- | scene/resources/visual_shader_nodes.cpp | 52 | ||||
-rw-r--r-- | scene/resources/visual_shader_nodes.h | 1 |
2 files changed, 53 insertions, 0 deletions
diff --git a/scene/resources/visual_shader_nodes.cpp b/scene/resources/visual_shader_nodes.cpp index cb8719fbef..018b7be81c 100644 --- a/scene/resources/visual_shader_nodes.cpp +++ b/scene/resources/visual_shader_nodes.cpp @@ -6497,6 +6497,58 @@ bool VisualShaderNodeTextureParameter::is_show_prop_names() const { return true; } +String VisualShaderNodeTextureParameter::get_warning(Shader::Mode p_mode, VisualShader::Type p_type) const { + if (texture_source != SOURCE_NONE) { + String texture_source_str; + + switch (texture_source) { + case SOURCE_SCREEN: { + texture_source_str = "Screen"; + } break; + case SOURCE_DEPTH: { + texture_source_str = "Depth"; + } break; + case SOURCE_NORMAL_ROUGHNESS: { + texture_source_str = "NormalRoughness"; + } break; + default: + break; + } + + if (texture_type == TYPE_NORMAL_MAP || texture_type == TYPE_ANISOTROPY) { + String texture_type_str; + + switch (texture_type) { + case TYPE_NORMAL_MAP: { + texture_type_str = "Normal Map"; + } break; + case TYPE_ANISOTROPY: { + texture_type_str = "Anisotropic"; + } break; + default: + break; + } + return vformat(RTR("'%s' type is incompatible with '%s' source."), texture_type_str, texture_source_str); + } else if (color_default != COLOR_DEFAULT_WHITE) { + String color_default_str; + + switch (color_default) { + case COLOR_DEFAULT_BLACK: { + color_default_str = "Black"; + } break; + case COLOR_DEFAULT_TRANSPARENT: { + color_default_str = "Transparent"; + } break; + default: + break; + } + return vformat(RTR("'%s' default color is incompatible with '%s' source."), color_default_str, texture_source_str); + } + } + + return ""; +} + HashMap<StringName, String> VisualShaderNodeTextureParameter::get_editable_properties_names() const { HashMap<StringName, String> names; names.insert("texture_type", RTR("Type")); diff --git a/scene/resources/visual_shader_nodes.h b/scene/resources/visual_shader_nodes.h index a23ae72def..7a37ffa0e0 100644 --- a/scene/resources/visual_shader_nodes.h +++ b/scene/resources/visual_shader_nodes.h @@ -2543,6 +2543,7 @@ public: virtual HashMap<StringName, String> get_editable_properties_names() const override; virtual bool is_show_prop_names() const override; + virtual String get_warning(Shader::Mode p_mode, VisualShader::Type p_type) const override; Vector<StringName> get_editable_properties() const override; |