Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extra warning messages to VisualShaderNodeTextureParameter #83729

Merged
merged 1 commit into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions scene/resources/visual_shader_nodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6346,6 +6346,7 @@ String get_sampler_hint(VisualShaderNodeTextureParameter::TextureType p_texture_
if (!repeat_code.is_empty()) {
if (!has_colon) {
code += " : ";
has_colon = true;
} else {
code += ", ";
}
Expand Down Expand Up @@ -6495,6 +6496,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"));
Expand Down
1 change: 1 addition & 0 deletions scene/resources/visual_shader_nodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -2452,6 +2452,7 @@ class VisualShaderNodeTextureParameter : public VisualShaderNodeParameter {

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;

Expand Down
Loading