diff options
Diffstat (limited to 'scene/resources/visual_shader.h')
-rw-r--r-- | scene/resources/visual_shader.h | 48 |
1 files changed, 32 insertions, 16 deletions
diff --git a/scene/resources/visual_shader.h b/scene/resources/visual_shader.h index 05d8950be9..e7d74b6c17 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,7 +189,7 @@ 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; @@ -187,7 +197,7 @@ class VisualShaderNode : public Resource { int connected_output_count = 0; protected: - bool simple_decl; + bool simple_decl = true; static void _bind_methods(); public: @@ -232,6 +242,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 +301,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 +315,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 +399,8 @@ public: }; private: - String uniform_name; - Qualifier qualifier; + String uniform_name = ""; + Qualifier qualifier = QUAL_NONE; bool global_code_generated = false; protected: @@ -435,8 +447,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 +456,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 +472,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; @@ -478,10 +494,10 @@ private: void _apply_port_changes(); protected: - Vector2 size; - String inputs; - String outputs; - bool editable; + Vector2 size = Size2(0, 0); + String inputs = ""; + String outputs = ""; + bool editable = false; struct Port { PortType type; @@ -549,7 +565,7 @@ class VisualShaderNodeExpression : public VisualShaderNodeGroupBase { GDCLASS(VisualShaderNodeExpression, VisualShaderNodeGroupBase); protected: - String expression; + String expression = ""; static void _bind_methods(); |