summaryrefslogtreecommitdiff
path: root/scene/resources
diff options
context:
space:
mode:
Diffstat (limited to 'scene/resources')
-rw-r--r--scene/resources/visual_shader.cpp64
-rw-r--r--scene/resources/visual_shader.h33
-rw-r--r--scene/resources/visual_shader_nodes.cpp28
-rw-r--r--scene/resources/visual_shader_nodes.h7
4 files changed, 132 insertions, 0 deletions
diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp
index 859546694f..e1e24ddab2 100644
--- a/scene/resources/visual_shader.cpp
+++ b/scene/resources/visual_shader.cpp
@@ -2667,6 +2667,70 @@ VisualShaderNodeResizableBase::VisualShaderNodeResizableBase() {
set_allow_v_resize(true);
}
+////////////// Comment
+
+String VisualShaderNodeComment::get_caption() const {
+ return title;
+}
+
+int VisualShaderNodeComment::get_input_port_count() const {
+ return 0;
+}
+
+VisualShaderNodeComment::PortType VisualShaderNodeComment::get_input_port_type(int p_port) const {
+ return PortType::PORT_TYPE_SCALAR;
+}
+
+String VisualShaderNodeComment::get_input_port_name(int p_port) const {
+ return String();
+}
+
+int VisualShaderNodeComment::get_output_port_count() const {
+ return 0;
+}
+
+VisualShaderNodeComment::PortType VisualShaderNodeComment::get_output_port_type(int p_port) const {
+ return PortType::PORT_TYPE_SCALAR;
+}
+
+String VisualShaderNodeComment::get_output_port_name(int p_port) const {
+ return String();
+}
+
+void VisualShaderNodeComment::set_title(const String &p_title) {
+ title = p_title;
+}
+
+String VisualShaderNodeComment::get_title() const {
+ return title;
+}
+
+void VisualShaderNodeComment::set_description(const String &p_description) {
+ description = p_description;
+}
+
+String VisualShaderNodeComment::get_description() const {
+ return description;
+}
+
+String VisualShaderNodeComment::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
+ return String();
+}
+
+void VisualShaderNodeComment::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_title", "title"), &VisualShaderNodeComment::set_title);
+ ClassDB::bind_method(D_METHOD("get_title"), &VisualShaderNodeComment::get_title);
+
+ ClassDB::bind_method(D_METHOD("set_description", "description"), &VisualShaderNodeComment::set_description);
+ ClassDB::bind_method(D_METHOD("get_description"), &VisualShaderNodeComment::get_description);
+
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "title"), "set_title", "get_title");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "description"), "set_description", "get_description");
+}
+
+VisualShaderNodeComment::VisualShaderNodeComment() {
+}
+
////////////// GroupBase
void VisualShaderNodeGroupBase::set_inputs(const String &p_inputs) {
diff --git a/scene/resources/visual_shader.h b/scene/resources/visual_shader.h
index ef724c7650..54a5c19049 100644
--- a/scene/resources/visual_shader.h
+++ b/scene/resources/visual_shader.h
@@ -421,6 +421,7 @@ public:
bool is_global_code_generated() const;
virtual bool is_qualifier_supported(Qualifier p_qual) const = 0;
+ virtual bool is_convertible_to_constant() const = 0;
virtual Vector<StringName> get_editable_properties() const override;
virtual String get_warning(Shader::Mode p_mode, VisualShader::Type p_type) const override;
@@ -510,6 +511,38 @@ public:
VisualShaderNodeResizableBase();
};
+class VisualShaderNodeComment : public VisualShaderNodeResizableBase {
+ GDCLASS(VisualShaderNodeComment, VisualShaderNodeResizableBase);
+
+protected:
+ String title = "Comment";
+ String description = "";
+
+protected:
+ static void _bind_methods();
+
+public:
+ virtual String get_caption() const override;
+
+ virtual int get_input_port_count() const override;
+ virtual PortType get_input_port_type(int p_port) const override;
+ virtual String get_input_port_name(int p_port) const override;
+
+ virtual int get_output_port_count() const override;
+ virtual PortType get_output_port_type(int p_port) const override;
+ virtual String get_output_port_name(int p_port) const override;
+
+ virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
+
+ void set_title(const String &p_title);
+ String get_title() const;
+
+ void set_description(const String &p_description);
+ String get_description() const;
+
+ VisualShaderNodeComment();
+};
+
class VisualShaderNodeGroupBase : public VisualShaderNodeResizableBase {
GDCLASS(VisualShaderNodeGroupBase, VisualShaderNodeResizableBase);
diff --git a/scene/resources/visual_shader_nodes.cpp b/scene/resources/visual_shader_nodes.cpp
index a99c09e89c..9c8d2a0981 100644
--- a/scene/resources/visual_shader_nodes.cpp
+++ b/scene/resources/visual_shader_nodes.cpp
@@ -3744,6 +3744,10 @@ bool VisualShaderNodeFloatUniform::is_qualifier_supported(Qualifier p_qual) cons
return true; // all qualifiers are supported
}
+bool VisualShaderNodeFloatUniform::is_convertible_to_constant() const {
+ return true; // conversion is allowed
+}
+
Vector<StringName> VisualShaderNodeFloatUniform::get_editable_properties() const {
Vector<StringName> props = VisualShaderNodeUniform::get_editable_properties();
props.push_back("hint");
@@ -3911,6 +3915,10 @@ bool VisualShaderNodeIntUniform::is_qualifier_supported(Qualifier p_qual) const
return true; // all qualifiers are supported
}
+bool VisualShaderNodeIntUniform::is_convertible_to_constant() const {
+ return true; // conversion is allowed
+}
+
Vector<StringName> VisualShaderNodeIntUniform::get_editable_properties() const {
Vector<StringName> props = VisualShaderNodeUniform::get_editable_properties();
props.push_back("hint");
@@ -4019,6 +4027,10 @@ bool VisualShaderNodeBooleanUniform::is_qualifier_supported(Qualifier p_qual) co
return true; // all qualifiers are supported
}
+bool VisualShaderNodeBooleanUniform::is_convertible_to_constant() const {
+ return true; // conversion is allowed
+}
+
Vector<StringName> VisualShaderNodeBooleanUniform::get_editable_properties() const {
Vector<StringName> props = VisualShaderNodeUniform::get_editable_properties();
props.push_back("default_value_enabled");
@@ -4113,6 +4125,10 @@ bool VisualShaderNodeColorUniform::is_qualifier_supported(Qualifier p_qual) cons
return true; // all qualifiers are supported
}
+bool VisualShaderNodeColorUniform::is_convertible_to_constant() const {
+ return true; // conversion is allowed
+}
+
Vector<StringName> VisualShaderNodeColorUniform::get_editable_properties() const {
Vector<StringName> props = VisualShaderNodeUniform::get_editable_properties();
props.push_back("default_value_enabled");
@@ -4209,6 +4225,10 @@ bool VisualShaderNodeVec3Uniform::is_qualifier_supported(Qualifier p_qual) const
return true; // all qualifiers are supported
}
+bool VisualShaderNodeVec3Uniform::is_convertible_to_constant() const {
+ return true; // conversion is allowed
+}
+
Vector<StringName> VisualShaderNodeVec3Uniform::get_editable_properties() const {
Vector<StringName> props = VisualShaderNodeUniform::get_editable_properties();
props.push_back("default_value_enabled");
@@ -4309,6 +4329,10 @@ bool VisualShaderNodeTransformUniform::is_qualifier_supported(Qualifier p_qual)
return true; // all qualifiers are supported
}
+bool VisualShaderNodeTransformUniform::is_convertible_to_constant() const {
+ return true; // conversion is allowed
+}
+
Vector<StringName> VisualShaderNodeTransformUniform::get_editable_properties() const {
Vector<StringName> props = VisualShaderNodeUniform::get_editable_properties();
props.push_back("default_value_enabled");
@@ -4494,6 +4518,10 @@ bool VisualShaderNodeTextureUniform::is_qualifier_supported(Qualifier p_qual) co
return false;
}
+bool VisualShaderNodeTextureUniform::is_convertible_to_constant() const {
+ return false; // conversion is not allowed
+}
+
VisualShaderNodeTextureUniform::VisualShaderNodeTextureUniform() {
simple_decl = false;
}
diff --git a/scene/resources/visual_shader_nodes.h b/scene/resources/visual_shader_nodes.h
index a5d0fe4649..594a494cf1 100644
--- a/scene/resources/visual_shader_nodes.h
+++ b/scene/resources/visual_shader_nodes.h
@@ -1574,6 +1574,7 @@ public:
float get_default_value() const;
bool is_qualifier_supported(Qualifier p_qual) const override;
+ bool is_convertible_to_constant() const override;
virtual Vector<StringName> get_editable_properties() const override;
@@ -1639,6 +1640,7 @@ public:
int get_default_value() const;
bool is_qualifier_supported(Qualifier p_qual) const override;
+ bool is_convertible_to_constant() const override;
virtual Vector<StringName> get_editable_properties() const override;
@@ -1683,6 +1685,7 @@ public:
bool get_default_value() const;
bool is_qualifier_supported(Qualifier p_qual) const override;
+ bool is_convertible_to_constant() const override;
virtual Vector<StringName> get_editable_properties() const override;
@@ -1724,6 +1727,7 @@ public:
Color get_default_value() const;
bool is_qualifier_supported(Qualifier p_qual) const override;
+ bool is_convertible_to_constant() const override;
virtual Vector<StringName> get_editable_properties() const override;
@@ -1766,6 +1770,7 @@ public:
Vector3 get_default_value() const;
bool is_qualifier_supported(Qualifier p_qual) const override;
+ bool is_convertible_to_constant() const override;
virtual Vector<StringName> get_editable_properties() const override;
@@ -1808,6 +1813,7 @@ public:
Transform get_default_value() const;
bool is_qualifier_supported(Qualifier p_qual) const override;
+ bool is_convertible_to_constant() const override;
virtual Vector<StringName> get_editable_properties() const override;
@@ -1865,6 +1871,7 @@ public:
ColorDefault get_color_default() const;
bool is_qualifier_supported(Qualifier p_qual) const override;
+ bool is_convertible_to_constant() const override;
VisualShaderNodeTextureUniform();
};