diff options
Diffstat (limited to 'scene/resources/visual_shader.cpp')
-rw-r--r-- | scene/resources/visual_shader.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp index 310a7ef4e4..7d0183e6b9 100644 --- a/scene/resources/visual_shader.cpp +++ b/scene/resources/visual_shader.cpp @@ -2156,12 +2156,43 @@ String VisualShaderNodeUniform::get_uniform_name() const { return uniform_name; } +void VisualShaderNodeUniform::set_qualifier(VisualShaderNodeUniform::Qualifier p_qual) { + qualifier = p_qual; + emit_changed(); +} + +VisualShaderNodeUniform::Qualifier VisualShaderNodeUniform::get_qualifier() const { + return qualifier; +} + void VisualShaderNodeUniform::_bind_methods() { ClassDB::bind_method(D_METHOD("set_uniform_name", "name"), &VisualShaderNodeUniform::set_uniform_name); ClassDB::bind_method(D_METHOD("get_uniform_name"), &VisualShaderNodeUniform::get_uniform_name); + ClassDB::bind_method(D_METHOD("set_qualifier", "qualifier"), &VisualShaderNodeUniform::set_qualifier); + ClassDB::bind_method(D_METHOD("get_qualifier"), &VisualShaderNodeUniform::get_qualifier); + ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "uniform_name"), "set_uniform_name", "get_uniform_name"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "qualifier", PROPERTY_HINT_ENUM, "None,Global,Instance"), "set_qualifier", "get_qualifier"); + + BIND_ENUM_CONSTANT(QUAL_NONE); + BIND_ENUM_CONSTANT(QUAL_GLOBAL); + BIND_ENUM_CONSTANT(QUAL_INSTANCE); +} + +String VisualShaderNodeUniform::_get_qual_str() const { + if (is_qualifier_supported(qualifier)) { + switch (qualifier) { + case QUAL_NONE: + break; + case QUAL_GLOBAL: + return "global "; + case QUAL_INSTANCE: + return "instance "; + } + } + return String(); } String VisualShaderNodeUniform::get_warning(Shader::Mode p_mode, VisualShader::Type p_type) const { @@ -2171,11 +2202,21 @@ String VisualShaderNodeUniform::get_warning(Shader::Mode p_mode, VisualShader::T if (keyword_list.find(uniform_name)) { return TTR("Uniform name cannot be equal to a shader keyword. Choose another name."); } + if (!is_qualifier_supported(qualifier)) { + return "This uniform type does not support that qualifier."; + } return String(); } +Vector<StringName> VisualShaderNodeUniform::get_editable_properties() const { + Vector<StringName> props; + props.push_back("qualifier"); + return props; +} + VisualShaderNodeUniform::VisualShaderNodeUniform() { + qualifier = QUAL_NONE; } ////////////// GroupBase |