summaryrefslogtreecommitdiff
path: root/scene/resources
diff options
context:
space:
mode:
authorYuri Roubinsky <chaosus89@gmail.com>2021-08-12 16:55:14 +0300
committerYuri Roubinsky <chaosus89@gmail.com>2021-08-12 19:40:45 +0300
commitc43b7c113f1158db6c4436122550d6402c92abd7 (patch)
treeb566a1554eac7651719e2ab674130d9643f6ae49 /scene/resources
parent9dd1debaf9e89aaeda58e5ca25924e844fbeb248 (diff)
Fix printing error about unsupported modifier on `TransformUniform`
Diffstat (limited to 'scene/resources')
-rw-r--r--scene/resources/visual_shader.cpp78
-rw-r--r--scene/resources/visual_shader_nodes.cpp5
2 files changed, 80 insertions, 3 deletions
diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp
index a6815da6f4..75dd7448e7 100644
--- a/scene/resources/visual_shader.cpp
+++ b/scene/resources/visual_shader.cpp
@@ -3081,10 +3081,84 @@ String VisualShaderNodeUniform::get_warning(Shader::Mode p_mode, VisualShader::T
List<String> keyword_list;
ShaderLanguage::get_keyword_list(&keyword_list);
if (keyword_list.find(uniform_name)) {
- return TTR("Uniform name cannot be equal to a shader keyword. Choose another name.");
+ return TTR("Shader keywords cannot be used as uniform names.\nChoose another name.");
}
if (!is_qualifier_supported(qualifier)) {
- return "This uniform type does not support that qualifier.";
+ String qualifier_str;
+ switch (qualifier) {
+ case QUAL_NONE:
+ break;
+ case QUAL_GLOBAL:
+ qualifier_str = "global";
+ break;
+ case QUAL_INSTANCE:
+ qualifier_str = "instance";
+ break;
+ }
+ return vformat(TTR("This uniform type does not support the '%s' qualifier."), qualifier_str);
+ } else if (qualifier == Qualifier::QUAL_GLOBAL) {
+ RS::GlobalVariableType gvt = RS::get_singleton()->global_variable_get_type(uniform_name);
+ if (gvt == RS::GLOBAL_VAR_TYPE_MAX) {
+ return vformat(TTR("Global uniform '%s' does not exist.\nCreate it in the Project Settings."), uniform_name);
+ }
+ bool incompatible_type = false;
+ switch (gvt) {
+ case RS::GLOBAL_VAR_TYPE_FLOAT: {
+ if (!Object::cast_to<VisualShaderNodeFloatUniform>(this)) {
+ incompatible_type = true;
+ }
+ } break;
+ case RS::GLOBAL_VAR_TYPE_INT: {
+ if (!Object::cast_to<VisualShaderNodeIntUniform>(this)) {
+ incompatible_type = true;
+ }
+ } break;
+ case RS::GLOBAL_VAR_TYPE_BOOL: {
+ if (!Object::cast_to<VisualShaderNodeBooleanUniform>(this)) {
+ incompatible_type = true;
+ }
+ } break;
+ case RS::GLOBAL_VAR_TYPE_COLOR: {
+ if (!Object::cast_to<VisualShaderNodeColorUniform>(this)) {
+ incompatible_type = true;
+ }
+ } break;
+ case RS::GLOBAL_VAR_TYPE_VEC3: {
+ if (!Object::cast_to<VisualShaderNodeVec3Uniform>(this)) {
+ incompatible_type = true;
+ }
+ } break;
+ case RS::GLOBAL_VAR_TYPE_TRANSFORM: {
+ if (!Object::cast_to<VisualShaderNodeTransformUniform>(this)) {
+ incompatible_type = true;
+ }
+ } break;
+ case RS::GLOBAL_VAR_TYPE_SAMPLER2D: {
+ if (!Object::cast_to<VisualShaderNodeTextureUniform>(this)) {
+ incompatible_type = true;
+ }
+ } break;
+ case RS::GLOBAL_VAR_TYPE_SAMPLER3D: {
+ if (!Object::cast_to<VisualShaderNodeTexture3DUniform>(this)) {
+ incompatible_type = true;
+ }
+ } break;
+ case RS::GLOBAL_VAR_TYPE_SAMPLER2DARRAY: {
+ if (!Object::cast_to<VisualShaderNodeTexture2DArrayUniform>(this)) {
+ incompatible_type = true;
+ }
+ } break;
+ case RS::GLOBAL_VAR_TYPE_SAMPLERCUBE: {
+ if (!Object::cast_to<VisualShaderNodeCubemapUniform>(this)) {
+ incompatible_type = true;
+ }
+ } break;
+ default:
+ break;
+ }
+ if (incompatible_type) {
+ return vformat(TTR("Global uniform '%s' has an incompatible type for this kind of node.\nChange it in the Project Settings."), uniform_name);
+ }
}
return String();
diff --git a/scene/resources/visual_shader_nodes.cpp b/scene/resources/visual_shader_nodes.cpp
index 6fd6fd8f3b..afe0bdfd5c 100644
--- a/scene/resources/visual_shader_nodes.cpp
+++ b/scene/resources/visual_shader_nodes.cpp
@@ -4575,7 +4575,10 @@ bool VisualShaderNodeTransformUniform::is_use_prop_slots() const {
}
bool VisualShaderNodeTransformUniform::is_qualifier_supported(Qualifier p_qual) const {
- return true; // all qualifiers are supported
+ if (p_qual == Qualifier::QUAL_INSTANCE) {
+ return false;
+ }
+ return true;
}
bool VisualShaderNodeTransformUniform::is_convertible_to_constant() const {