diff options
Diffstat (limited to 'scene/resources/visual_shader_nodes.h')
-rw-r--r-- | scene/resources/visual_shader_nodes.h | 230 |
1 files changed, 199 insertions, 31 deletions
diff --git a/scene/resources/visual_shader_nodes.h b/scene/resources/visual_shader_nodes.h index 3d57fd0efc..035e39230c 100644 --- a/scene/resources/visual_shader_nodes.h +++ b/scene/resources/visual_shader_nodes.h @@ -37,8 +37,8 @@ /// CONSTANTS /////////////////////////////////////// -class VisualShaderNodeScalarConstant : public VisualShaderNode { - GDCLASS(VisualShaderNodeScalarConstant, VisualShaderNode); +class VisualShaderNodeFloatConstant : public VisualShaderNode { + GDCLASS(VisualShaderNodeFloatConstant, VisualShaderNode); float constant; protected: @@ -62,7 +62,37 @@ public: virtual Vector<StringName> get_editable_properties() const; - VisualShaderNodeScalarConstant(); + VisualShaderNodeFloatConstant(); +}; + +/////////////////////////////////////// + +class VisualShaderNodeIntConstant : public VisualShaderNode { + GDCLASS(VisualShaderNodeIntConstant, VisualShaderNode); + int constant; + +protected: + static void _bind_methods(); + +public: + virtual String get_caption() const; + + virtual int get_input_port_count() const; + virtual PortType get_input_port_type(int p_port) const; + virtual String get_input_port_name(int p_port) const; + + virtual int get_output_port_count() const; + virtual PortType get_output_port_type(int p_port) const; + virtual String get_output_port_name(int p_port) const; + + 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; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty + + void set_constant(int p_value); + int get_constant() const; + + virtual Vector<StringName> get_editable_properties() const; + + VisualShaderNodeIntConstant(); }; /////////////////////////////////////// @@ -191,7 +221,7 @@ public: class VisualShaderNodeTexture : public VisualShaderNode { GDCLASS(VisualShaderNodeTexture, VisualShaderNode); - Ref<Texture> texture; + Ref<Texture2D> texture; public: enum Source { @@ -236,8 +266,8 @@ public: void set_source(Source p_source); Source get_source() const; - void set_texture(Ref<Texture> p_value); - Ref<Texture> get_texture() const; + void set_texture(Ref<Texture2D> p_value); + Ref<Texture2D> get_texture() const; void set_texture_type(TextureType p_type); TextureType get_texture_type() const; @@ -254,9 +284,9 @@ VARIANT_ENUM_CAST(VisualShaderNodeTexture::Source) /////////////////////////////////////// -class VisualShaderNodeCubeMap : public VisualShaderNode { - GDCLASS(VisualShaderNodeCubeMap, VisualShaderNode); - Ref<CubeMap> cube_map; +class VisualShaderNodeCubemap : public VisualShaderNode { + GDCLASS(VisualShaderNodeCubemap, VisualShaderNode); + Ref<Cubemap> cube_map; public: enum Source { @@ -296,26 +326,26 @@ public: void set_source(Source p_source); Source get_source() const; - void set_cube_map(Ref<CubeMap> p_value); - Ref<CubeMap> get_cube_map() const; + void set_cube_map(Ref<Cubemap> p_value); + Ref<Cubemap> get_cube_map() const; void set_texture_type(TextureType p_type); TextureType get_texture_type() const; virtual Vector<StringName> get_editable_properties() const; - VisualShaderNodeCubeMap(); + VisualShaderNodeCubemap(); }; -VARIANT_ENUM_CAST(VisualShaderNodeCubeMap::TextureType) -VARIANT_ENUM_CAST(VisualShaderNodeCubeMap::Source) +VARIANT_ENUM_CAST(VisualShaderNodeCubemap::TextureType) +VARIANT_ENUM_CAST(VisualShaderNodeCubemap::Source) /////////////////////////////////////// /// OPS /////////////////////////////////////// -class VisualShaderNodeScalarOp : public VisualShaderNode { - GDCLASS(VisualShaderNodeScalarOp, VisualShaderNode); +class VisualShaderNodeFloatOp : public VisualShaderNode { + GDCLASS(VisualShaderNodeFloatOp, VisualShaderNode); public: enum Operator { @@ -354,10 +384,52 @@ public: virtual Vector<StringName> get_editable_properties() const; - VisualShaderNodeScalarOp(); + VisualShaderNodeFloatOp(); }; -VARIANT_ENUM_CAST(VisualShaderNodeScalarOp::Operator) +VARIANT_ENUM_CAST(VisualShaderNodeFloatOp::Operator) + +class VisualShaderNodeIntOp : public VisualShaderNode { + GDCLASS(VisualShaderNodeIntOp, VisualShaderNode); + +public: + enum Operator { + OP_ADD, + OP_SUB, + OP_MUL, + OP_DIV, + OP_MOD, + OP_MAX, + OP_MIN, + }; + +protected: + Operator op; + + static void _bind_methods(); + +public: + virtual String get_caption() const; + + virtual int get_input_port_count() const; + virtual PortType get_input_port_type(int p_port) const; + virtual String get_input_port_name(int p_port) const; + + virtual int get_output_port_count() const; + virtual PortType get_output_port_type(int p_port) const; + virtual String get_output_port_name(int p_port) const; + + 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; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty + + void set_operator(Operator p_op); + Operator get_operator() const; + + virtual Vector<StringName> get_editable_properties() const; + + VisualShaderNodeIntOp(); +}; + +VARIANT_ENUM_CAST(VisualShaderNodeIntOp::Operator) class VisualShaderNodeVectorOp : public VisualShaderNode { GDCLASS(VisualShaderNodeVectorOp, VisualShaderNode); @@ -539,11 +611,11 @@ public: VARIANT_ENUM_CAST(VisualShaderNodeTransformVecMult::Operator) /////////////////////////////////////// -/// SCALAR FUNC +/// FLOAT FUNC /////////////////////////////////////// -class VisualShaderNodeScalarFunc : public VisualShaderNode { - GDCLASS(VisualShaderNodeScalarFunc, VisualShaderNode); +class VisualShaderNodeFloatFunc : public VisualShaderNode { + GDCLASS(VisualShaderNodeFloatFunc, VisualShaderNode); public: enum Function { @@ -604,10 +676,53 @@ public: virtual Vector<StringName> get_editable_properties() const; - VisualShaderNodeScalarFunc(); + VisualShaderNodeFloatFunc(); +}; + +VARIANT_ENUM_CAST(VisualShaderNodeFloatFunc::Function) + +/////////////////////////////////////// +/// INT FUNC +/////////////////////////////////////// + +class VisualShaderNodeIntFunc : public VisualShaderNode { + GDCLASS(VisualShaderNodeIntFunc, VisualShaderNode); + +public: + enum Function { + FUNC_ABS, + FUNC_CLAMP, + FUNC_NEGATE, + FUNC_SIGN, + }; + +protected: + Function func; + + static void _bind_methods(); + +public: + virtual String get_caption() const; + + virtual int get_input_port_count() const; + virtual PortType get_input_port_type(int p_port) const; + virtual String get_input_port_name(int p_port) const; + + virtual int get_output_port_count() const; + virtual PortType get_output_port_type(int p_port) const; + virtual String get_output_port_name(int p_port) const; + + 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; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty + + void set_function(Function p_func); + Function get_function() const; + + virtual Vector<StringName> get_editable_properties() const; + + VisualShaderNodeIntFunc(); }; -VARIANT_ENUM_CAST(VisualShaderNodeScalarFunc::Function) +VARIANT_ENUM_CAST(VisualShaderNodeIntFunc::Function) /////////////////////////////////////// /// VECTOR FUNC @@ -1297,8 +1412,8 @@ public: /// UNIFORMS /////////////////////////////////////// -class VisualShaderNodeScalarUniform : public VisualShaderNodeUniform { - GDCLASS(VisualShaderNodeScalarUniform, VisualShaderNodeUniform); +class VisualShaderNodeFloatUniform : public VisualShaderNodeUniform { + GDCLASS(VisualShaderNodeFloatUniform, VisualShaderNodeUniform); public: enum Hint { @@ -1344,10 +1459,62 @@ public: virtual Vector<StringName> get_editable_properties() const; - VisualShaderNodeScalarUniform(); + VisualShaderNodeFloatUniform(); +}; + +VARIANT_ENUM_CAST(VisualShaderNodeFloatUniform::Hint) + +class VisualShaderNodeIntUniform : public VisualShaderNodeUniform { + GDCLASS(VisualShaderNodeIntUniform, VisualShaderNodeUniform); + +public: + enum Hint { + HINT_NONE, + HINT_RANGE, + HINT_RANGE_STEP, + }; + +private: + Hint hint; + int hint_range_min; + int hint_range_max; + int hint_range_step; + +protected: + static void _bind_methods(); + +public: + virtual String get_caption() const; + + virtual int get_input_port_count() const; + virtual PortType get_input_port_type(int p_port) const; + virtual String get_input_port_name(int p_port) const; + + virtual int get_output_port_count() const; + virtual PortType get_output_port_type(int p_port) const; + virtual String get_output_port_name(int p_port) const; + + virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const; + 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; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty + + void set_hint(Hint p_hint); + Hint get_hint() const; + + void set_min(int p_value); + int get_min() const; + + void set_max(int p_value); + int get_max() const; + + void set_step(int p_value); + int get_step() const; + + virtual Vector<StringName> get_editable_properties() const; + + VisualShaderNodeIntUniform(); }; -VARIANT_ENUM_CAST(VisualShaderNodeScalarUniform::Hint) +VARIANT_ENUM_CAST(VisualShaderNodeIntUniform::Hint) /////////////////////////////////////// @@ -1514,8 +1681,8 @@ public: /////////////////////////////////////// -class VisualShaderNodeCubeMapUniform : public VisualShaderNodeTextureUniform { - GDCLASS(VisualShaderNodeCubeMapUniform, VisualShaderNodeTextureUniform); +class VisualShaderNodeCubemapUniform : public VisualShaderNodeTextureUniform { + GDCLASS(VisualShaderNodeCubemapUniform, VisualShaderNodeTextureUniform); public: virtual String get_caption() const; @@ -1532,7 +1699,7 @@ public: virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const; 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; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty - VisualShaderNodeCubeMapUniform(); + VisualShaderNodeCubemapUniform(); }; /////////////////////////////////////// @@ -1669,9 +1836,10 @@ class VisualShaderNodeCompare : public VisualShaderNode { public: enum ComparisonType { CTYPE_SCALAR, + CTYPE_SCALAR_INT, CTYPE_VECTOR, CTYPE_BOOLEAN, - CTYPE_TRANSFORM + CTYPE_TRANSFORM, }; enum Function { |