summaryrefslogtreecommitdiff
path: root/scene/resources/visual_shader.h
diff options
context:
space:
mode:
Diffstat (limited to 'scene/resources/visual_shader.h')
-rw-r--r--scene/resources/visual_shader.h79
1 files changed, 54 insertions, 25 deletions
diff --git a/scene/resources/visual_shader.h b/scene/resources/visual_shader.h
index 05d8950be9..e3d8dae032 100644
--- a/scene/resources/visual_shader.h
+++ b/scene/resources/visual_shader.h
@@ -50,6 +50,9 @@ public:
TYPE_VERTEX,
TYPE_FRAGMENT,
TYPE_LIGHT,
+ TYPE_EMIT,
+ TYPE_PROCESS,
+ TYPE_END,
TYPE_MAX
};
@@ -66,6 +69,8 @@ public:
};
private:
+ Type current_type;
+
struct Node {
Ref<VisualShaderNode> node;
Vector2 position;
@@ -77,7 +82,7 @@ private:
List<Connection> connections;
} graph[TYPE_MAX];
- Shader::Mode shader_mode;
+ Shader::Mode shader_mode = Shader::MODE_SPATIAL;
mutable String previous_code;
Array _get_node_connections(Type p_type) const;
@@ -94,7 +99,7 @@ private:
static RenderModeEnums render_mode_enums[];
- volatile mutable bool dirty;
+ volatile mutable bool dirty = true;
void _queue_update();
union ConnectionKey {
@@ -111,6 +116,7 @@ private:
Error _write_node(Type p_type, StringBuilder &global_code, StringBuilder &global_code_per_node, Map<Type, StringBuilder> &global_code_per_func, StringBuilder &code, Vector<DefaultTextureParam> &def_tex_params, const VMap<ConnectionKey, const List<Connection>::Element *> &input_connections, const VMap<ConnectionKey, const List<Connection>::Element *> &output_connections, int node, Set<int> &processed, bool for_preview, Set<StringName> &r_classes) const;
void _input_type_changed(Type p_type, int p_id);
+ bool has_func_name(RenderingServer::ShaderMode p_mode, const String &p_func_name) const;
protected:
virtual void _update_shader() const override;
@@ -120,6 +126,10 @@ protected:
bool _get(const StringName &p_name, Variant &r_ret) const;
void _get_property_list(List<PropertyInfo> *p_list) const;
+public: // internal methods
+ void set_shader_type(Type p_type);
+ Type get_shader_type() const;
+
public:
void set_version(const String &p_version);
String get_version() const;
@@ -179,15 +189,14 @@ VARIANT_ENUM_CAST(VisualShader::Type)
class VisualShaderNode : public Resource {
GDCLASS(VisualShaderNode, Resource);
- int port_preview;
+ int port_preview = -1;
Map<int, Variant> default_input_values;
Map<int, bool> connected_input_ports;
- Map<int, bool> connected_output_ports;
- int connected_output_count = 0;
+ Map<int, int> connected_output_ports;
protected:
- bool simple_decl;
+ bool simple_decl = true;
static void _bind_methods();
public:
@@ -232,6 +241,8 @@ public:
virtual bool is_generate_input_var(int p_port) const;
virtual bool is_code_generated() const;
+ virtual bool is_show_prop_names() const;
+ virtual bool is_use_prop_slots() const;
virtual Vector<StringName> get_editable_properties() const;
@@ -289,8 +300,8 @@ class VisualShaderNodeInput : public VisualShaderNode {
GDCLASS(VisualShaderNodeInput, VisualShaderNode);
friend class VisualShader;
- VisualShader::Type shader_type;
- Shader::Mode shader_mode;
+ VisualShader::Type shader_type = VisualShader::TYPE_MAX;
+ Shader::Mode shader_mode = Shader::MODE_MAX;
struct Port {
Shader::Mode mode;
@@ -303,7 +314,7 @@ class VisualShaderNodeInput : public VisualShaderNode {
static const Port ports[];
static const Port preview_ports[];
- String input_name;
+ String input_name = "[None]";
protected:
static void _bind_methods();
@@ -387,8 +398,8 @@ public:
};
private:
- String uniform_name;
- Qualifier qualifier;
+ String uniform_name = "";
+ Qualifier qualifier = QUAL_NONE;
bool global_code_generated = false;
protected:
@@ -435,8 +446,8 @@ public:
};
private:
- String uniform_name;
- UniformType uniform_type;
+ String uniform_name = "[None]";
+ UniformType uniform_type = UniformType::UNIFORM_TYPE_FLOAT;
protected:
static void _bind_methods();
@@ -444,6 +455,7 @@ protected:
public:
static void add_uniform(const String &p_name, UniformType p_type);
static void clear_uniforms();
+ static bool has_uniform(const String &p_name);
public:
virtual String get_caption() const override;
@@ -459,6 +471,9 @@ public:
void set_uniform_name(const String &p_name);
String get_uniform_name() const;
+ void _set_uniform_type(int p_uniform_type);
+ int _get_uniform_type() const;
+
int get_uniforms_count() const;
String get_uniform_name_by_index(int p_idx) const;
UniformType get_uniform_type_by_name(const String &p_name) const;
@@ -471,17 +486,36 @@ public:
VisualShaderNodeUniformRef();
};
-class VisualShaderNodeGroupBase : public VisualShaderNode {
- GDCLASS(VisualShaderNodeGroupBase, VisualShaderNode);
+class VisualShaderNodeResizableBase : public VisualShaderNode {
+ GDCLASS(VisualShaderNodeResizableBase, VisualShaderNode);
+
+protected:
+ Vector2 size = Size2(0, 0);
+ bool allow_v_resize = true;
+
+protected:
+ static void _bind_methods();
+
+public:
+ void set_size(const Vector2 &p_size);
+ Vector2 get_size() const;
+
+ bool is_allow_v_resize() const;
+ void set_allow_v_resize(bool p_enabled);
+
+ VisualShaderNodeResizableBase();
+};
+
+class VisualShaderNodeGroupBase : public VisualShaderNodeResizableBase {
+ GDCLASS(VisualShaderNodeGroupBase, VisualShaderNodeResizableBase);
private:
void _apply_port_changes();
protected:
- Vector2 size;
- String inputs;
- String outputs;
- bool editable;
+ String inputs = "";
+ String outputs = "";
+ bool editable = false;
struct Port {
PortType type;
@@ -496,11 +530,6 @@ protected:
static void _bind_methods();
public:
- virtual String get_caption() const override;
-
- void set_size(const Vector2 &p_size);
- Vector2 get_size() const;
-
void set_inputs(const String &p_inputs);
String get_inputs() const;
@@ -549,7 +578,7 @@ class VisualShaderNodeExpression : public VisualShaderNodeGroupBase {
GDCLASS(VisualShaderNodeExpression, VisualShaderNodeGroupBase);
protected:
- String expression;
+ String expression = "";
static void _bind_methods();