Docs for some nodes in visual shader

Fix typo in `VisualShaderNodeCompare.ComparisonType` name.
This commit is contained in:
Yuri Roubinsky 2020-01-23 10:31:45 +03:00 committed by Rémi Verschelde
parent c66144738b
commit ce43c92208
10 changed files with 132 additions and 15 deletions

View file

@ -11,6 +11,7 @@
<return type="Array"> <return type="Array">
</return> </return>
<description> <description>
Returns an [Array] containing default values for all of the input ports of the node in the form [code][index0, value0, index1, value1, ...][/code].
</description> </description>
</method> </method>
<method name="get_input_port_default_value" qualifiers="const"> <method name="get_input_port_default_value" qualifiers="const">
@ -19,6 +20,7 @@
<argument index="0" name="port" type="int"> <argument index="0" name="port" type="int">
</argument> </argument>
<description> <description>
Returns the default value of the input [code]port[/code].
</description> </description>
</method> </method>
<method name="set_default_input_values"> <method name="set_default_input_values">
@ -27,6 +29,7 @@
<argument index="0" name="values" type="Array"> <argument index="0" name="values" type="Array">
</argument> </argument>
<description> <description>
Sets the default input ports values using an [Array] of the form [code][index0, value0, index1, value1, ...][/code]. For example: [code][0, Vector3(0, 0, 0), 1, Vector3(0, 0, 0)][/code].
</description> </description>
</method> </method>
<method name="set_input_port_default_value"> <method name="set_input_port_default_value">
@ -37,16 +40,19 @@
<argument index="1" name="value" type="Variant"> <argument index="1" name="value" type="Variant">
</argument> </argument>
<description> <description>
Sets the default value for the selected input [code]port[/code].
</description> </description>
</method> </method>
</methods> </methods>
<members> <members>
<member name="output_port_for_preview" type="int" setter="set_output_port_for_preview" getter="get_output_port_for_preview" default="-1"> <member name="output_port_for_preview" type="int" setter="set_output_port_for_preview" getter="get_output_port_for_preview" default="-1">
Sets the output port index which will be showed for preview. If set to [code]-1[/code] no port will be open for preview.
</member> </member>
</members> </members>
<signals> <signals>
<signal name="editor_refresh_request"> <signal name="editor_refresh_request">
<description> <description>
Emitted when the node requests an editor refresh. Currently called only in setter of [member VisualShaderNodeTexture.source], [VisualShaderNodeTexture], and [VisualShaderNodeCubeMap] (and their derivatives).
</description> </description>
</signal> </signal>
</signals> </signals>

View file

@ -1,8 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualShaderNodeBooleanConstant" inherits="VisualShaderNode" category="Core" version="3.2"> <class name="VisualShaderNodeBooleanConstant" inherits="VisualShaderNode" category="Core" version="3.2">
<brief_description> <brief_description>
A boolean constant to be used within the visual shader graph.
</brief_description> </brief_description>
<description> <description>
Has only one output port and no inputs.
Translated to [code]bool[/code] in the shader language.
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>
@ -10,6 +13,7 @@
</methods> </methods>
<members> <members>
<member name="constant" type="bool" setter="set_constant" getter="get_constant" default="false"> <member name="constant" type="bool" setter="set_constant" getter="get_constant" default="false">
A boolean constant which represents a state of this node.
</member> </member>
</members> </members>
<constants> <constants>

View file

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualShaderNodeBooleanUniform" inherits="VisualShaderNodeUniform" category="Core" version="3.2"> <class name="VisualShaderNodeBooleanUniform" inherits="VisualShaderNodeUniform" category="Core" version="3.2">
<brief_description> <brief_description>
A boolean uniform to be used within the visual shader graph.
</brief_description> </brief_description>
<description> <description>
Translated to [code]uniform bool[/code] in the shader language.
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>

View file

@ -1,8 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualShaderNodeColorConstant" inherits="VisualShaderNode" category="Core" version="3.2"> <class name="VisualShaderNodeColorConstant" inherits="VisualShaderNode" category="Core" version="3.2">
<brief_description> <brief_description>
A [Color] constant to be used within the visual shader graph.
</brief_description> </brief_description>
<description> <description>
Has two output ports representing RGB and alpha channels of [Color].
Translated to [code]vec3 rgb[/code] and [code]float alpha[/code] in the shader language.
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>
@ -10,6 +13,7 @@
</methods> </methods>
<members> <members>
<member name="constant" type="Color" setter="set_constant" getter="get_constant" default="Color( 1, 1, 1, 1 )"> <member name="constant" type="Color" setter="set_constant" getter="get_constant" default="Color( 1, 1, 1, 1 )">
A [Color] constant which represents a state of this node.
</member> </member>
</members> </members>
<constants> <constants>

View file

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualShaderNodeColorFunc" inherits="VisualShaderNode" category="Core" version="3.2"> <class name="VisualShaderNodeColorFunc" inherits="VisualShaderNode" category="Core" version="3.2">
<brief_description> <brief_description>
A [Color] function to be used within the visual shader graph.
</brief_description> </brief_description>
<description> <description>
Accept a [Color] to the input port and transform it according to [member function].
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>
@ -10,12 +12,29 @@
</methods> </methods>
<members> <members>
<member name="function" type="int" setter="set_function" getter="get_function" enum="VisualShaderNodeColorFunc.Function" default="0"> <member name="function" type="int" setter="set_function" getter="get_function" enum="VisualShaderNodeColorFunc.Function" default="0">
A function to be applied to the input color. See [enum Function] for options.
</member> </member>
</members> </members>
<constants> <constants>
<constant name="FUNC_GRAYSCALE" value="0" enum="Function"> <constant name="FUNC_GRAYSCALE" value="0" enum="Function">
Converts the color to grayscale using the following formula:
[codeblock]
vec3 c = input;
float max1 = max(c.r, c.g);
float max2 = max(max1, c.b);
float max3 = max(max1, max2);
return vec3(max3, max3, max3);
[/codeblock]
</constant> </constant>
<constant name="FUNC_SEPIA" value="1" enum="Function"> <constant name="FUNC_SEPIA" value="1" enum="Function">
Applies sepia tone effect using the following formula:
[codeblock]
vec3 c = input;
float r = (c.r * 0.393) + (c.g * 0.769) + (c.b * 0.189);
float g = (c.r * 0.349) + (c.g * 0.686) + (c.b * 0.168);
float b = (c.r * 0.272) + (c.g * 0.534) + (c.b * 0.131);
return vec3(r, g, b);
[/codeblock]
</constant> </constant>
</constants> </constants>
</class> </class>

View file

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualShaderNodeColorOp" inherits="VisualShaderNode" category="Core" version="3.2"> <class name="VisualShaderNodeColorOp" inherits="VisualShaderNode" category="Core" version="3.2">
<brief_description> <brief_description>
A [Color] operator to be used within the visual shader graph.
</brief_description> </brief_description>
<description> <description>
Applies [member operator] to two color inputs.
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>
@ -10,26 +12,87 @@
</methods> </methods>
<members> <members>
<member name="operator" type="int" setter="set_operator" getter="get_operator" enum="VisualShaderNodeColorOp.Operator" default="0"> <member name="operator" type="int" setter="set_operator" getter="get_operator" enum="VisualShaderNodeColorOp.Operator" default="0">
An operator to be applied to the inputs. See [enum Operator] for options.
</member> </member>
</members> </members>
<constants> <constants>
<constant name="OP_SCREEN" value="0" enum="Operator"> <constant name="OP_SCREEN" value="0" enum="Operator">
Produce a screen effect with the following formula:
[codeblock]
result = vec3(1.0) - (vec3(1.0) - a) * (vec3(1.0) - b);
[/codeblock]
</constant> </constant>
<constant name="OP_DIFFERENCE" value="1" enum="Operator"> <constant name="OP_DIFFERENCE" value="1" enum="Operator">
Produce a difference effect with the following formula:
[codeblock]
result = abs(a - b);
[/codeblock]
</constant> </constant>
<constant name="OP_DARKEN" value="2" enum="Operator"> <constant name="OP_DARKEN" value="2" enum="Operator">
Produce a darken effect with the following formula:
[codeblock]
result = min(a, b);
[/codeblock]
</constant> </constant>
<constant name="OP_LIGHTEN" value="3" enum="Operator"> <constant name="OP_LIGHTEN" value="3" enum="Operator">
Produce a lighten effect with the following formula:
[codeblock]
result = max(a, b);
[/codeblock]
</constant> </constant>
<constant name="OP_OVERLAY" value="4" enum="Operator"> <constant name="OP_OVERLAY" value="4" enum="Operator">
Produce an overlay effect with the following formula:
[codeblock]
for (int i = 0; i &lt; 3; i++) {
float base = a[i];
float blend = b[i];
if (base &lt; 0.5) {
result[i] = 2.0 * base * blend;
} else {
result[i] = 1.0 - 2.0 * (1.0 - blend) * (1.0 - base);
}
}
[/codeblock]
</constant> </constant>
<constant name="OP_DODGE" value="5" enum="Operator"> <constant name="OP_DODGE" value="5" enum="Operator">
Produce a dodge effect with the following formula:
[codeblock]
result = a / (vec3(1.0) - b);
[/codeblock]
</constant> </constant>
<constant name="OP_BURN" value="6" enum="Operator"> <constant name="OP_BURN" value="6" enum="Operator">
Produce a burn effect with the following formula:
[codeblock]
result = vec3(1.0) - (vec3(1.0) - a) / b;
[/codeblock]
</constant> </constant>
<constant name="OP_SOFT_LIGHT" value="7" enum="Operator"> <constant name="OP_SOFT_LIGHT" value="7" enum="Operator">
Produce a soft light effect with the following formula:
[codeblock]
for (int i = 0; i &lt; 3; i++) {
float base = a[i];
float blend = b[i];
if (base &lt; 0.5) {
result[i] = base * (blend + 0.5);
} else {
result[i] = 1.0 - (1.0 - base) * (1.0 - (blend - 0.5));
}
}
[/codeblock]
</constant> </constant>
<constant name="OP_HARD_LIGHT" value="8" enum="Operator"> <constant name="OP_HARD_LIGHT" value="8" enum="Operator">
Produce a hard light effect with the following formula:
[codeblock]
for (int i = 0; i &lt; 3; i++) {
float base = a[i];
float blend = b[i];
if (base &lt; 0.5) {
result[i] = base * (2.0 * blend);
} else {
result[i] = 1.0 - (1.0 - base) * (1.0 - 2.0 * (blend - 0.5));
}
}
[/codeblock]
</constant> </constant>
</constants> </constants>
</class> </class>

View file

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualShaderNodeColorUniform" inherits="VisualShaderNodeUniform" category="Core" version="3.2"> <class name="VisualShaderNodeColorUniform" inherits="VisualShaderNodeUniform" category="Core" version="3.2">
<brief_description> <brief_description>
A [Color] uniform to be used within the visual shader graph.
</brief_description> </brief_description>
<description> <description>
Translated to [code]uniform vec4[/code] in the shader language.
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>

View file

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualShaderNodeCompare" inherits="VisualShaderNode" category="Core" version="3.2"> <class name="VisualShaderNodeCompare" inherits="VisualShaderNode" category="Core" version="3.2">
<brief_description> <brief_description>
A comparison function for common types within the visual shader graph.
</brief_description> </brief_description>
<description> <description>
Compares [code]a[/code] and [code]b[/code] of [member type] by [member function]. Returns a boolean scalar. Translates to [code]if[/code] instruction in shader code.
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>
@ -10,36 +12,51 @@
</methods> </methods>
<members> <members>
<member name="condition" type="int" setter="set_condition" getter="get_condition" enum="VisualShaderNodeCompare.Condition" default="0"> <member name="condition" type="int" setter="set_condition" getter="get_condition" enum="VisualShaderNodeCompare.Condition" default="0">
Extra condition which is applied if [member type] is set to [constant CTYPE_VECTOR].
</member> </member>
<member name="function" type="int" setter="set_function" getter="get_function" enum="VisualShaderNodeCompare.Function" default="0"> <member name="function" type="int" setter="set_function" getter="get_function" enum="VisualShaderNodeCompare.Function" default="0">
A comparison function. See [enum Function] for options.
</member> </member>
<member name="type" type="int" setter="set_comparsion_type" getter="get_comparsion_type" enum="VisualShaderNodeCompare.ComparsionType" default="0"> <member name="type" type="int" setter="set_comparison_type" getter="get_comparison_type" enum="VisualShaderNodeCompare.ComparisonType" default="0">
The type to be used in the comparison. See [enum ComparisonType] for options.
</member> </member>
</members> </members>
<constants> <constants>
<constant name="CTYPE_SCALAR" value="0" enum="ComparsionType"> <constant name="CTYPE_SCALAR" value="0" enum="ComparisonType">
A floating-point scalar.
</constant> </constant>
<constant name="CTYPE_VECTOR" value="1" enum="ComparsionType"> <constant name="CTYPE_VECTOR" value="1" enum="ComparisonType">
A 3D vector type.
</constant> </constant>
<constant name="CTYPE_BOOLEAN" value="2" enum="ComparsionType"> <constant name="CTYPE_BOOLEAN" value="2" enum="ComparisonType">
A boolean type.
</constant> </constant>
<constant name="CTYPE_TRANSFORM" value="3" enum="ComparsionType"> <constant name="CTYPE_TRANSFORM" value="3" enum="ComparisonType">
A transform ([code]mat4[/code]) type.
</constant> </constant>
<constant name="FUNC_EQUAL" value="0" enum="Function"> <constant name="FUNC_EQUAL" value="0" enum="Function">
Comparison for equality ([code]a == b[/code]).
</constant> </constant>
<constant name="FUNC_NOT_EQUAL" value="1" enum="Function"> <constant name="FUNC_NOT_EQUAL" value="1" enum="Function">
Comparison for inequality ([code]a != b[/code]).
</constant> </constant>
<constant name="FUNC_GREATER_THAN" value="2" enum="Function"> <constant name="FUNC_GREATER_THAN" value="2" enum="Function">
Comparison for greater than ([code]a &gt; b[/code]). Cannot be used if [member type] set to [constant CTYPE_BOOLEAN] or [constant CTYPE_TRANSFORM].
</constant> </constant>
<constant name="FUNC_GREATER_THAN_EQUAL" value="3" enum="Function"> <constant name="FUNC_GREATER_THAN_EQUAL" value="3" enum="Function">
Comparison for greater than or equal ([code]a &gt;= b[/code]). Cannot be used if [member type] set to [constant CTYPE_BOOLEAN] or [constant CTYPE_TRANSFORM].
</constant> </constant>
<constant name="FUNC_LESS_THAN" value="4" enum="Function"> <constant name="FUNC_LESS_THAN" value="4" enum="Function">
Comparison for less than ([code]a &lt; b[/code]). Cannot be used if [member type] set to [constant CTYPE_BOOLEAN] or [constant CTYPE_TRANSFORM].
</constant> </constant>
<constant name="FUNC_LESS_THAN_EQUAL" value="5" enum="Function"> <constant name="FUNC_LESS_THAN_EQUAL" value="5" enum="Function">
Comparison for less than or equal ([code]a &lt; b[/code]). Cannot be used if [member type] set to [constant CTYPE_BOOLEAN] or [constant CTYPE_TRANSFORM].
</constant> </constant>
<constant name="COND_ALL" value="0" enum="Condition"> <constant name="COND_ALL" value="0" enum="Condition">
The result will be true if all of component in vector satisfy the comparison condition.
</constant> </constant>
<constant name="COND_ANY" value="1" enum="Condition"> <constant name="COND_ANY" value="1" enum="Condition">
The result will be true if any of component in vector satisfy the comparison condition.
</constant> </constant>
</constants> </constants>
</class> </class>

View file

@ -3929,7 +3929,7 @@ String VisualShaderNodeCompare::generate_code(Shader::Mode p_mode, VisualShader:
return code; return code;
} }
void VisualShaderNodeCompare::set_comparsion_type(ComparsionType p_type) { void VisualShaderNodeCompare::set_comparison_type(ComparisonType p_type) {
ctype = p_type; ctype = p_type;
@ -3954,7 +3954,7 @@ void VisualShaderNodeCompare::set_comparsion_type(ComparsionType p_type) {
emit_changed(); emit_changed();
} }
VisualShaderNodeCompare::ComparsionType VisualShaderNodeCompare::get_comparsion_type() const { VisualShaderNodeCompare::ComparisonType VisualShaderNodeCompare::get_comparison_type() const {
return ctype; return ctype;
} }
@ -3992,8 +3992,8 @@ Vector<StringName> VisualShaderNodeCompare::get_editable_properties() const {
void VisualShaderNodeCompare::_bind_methods() { void VisualShaderNodeCompare::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_comparsion_type", "type"), &VisualShaderNodeCompare::set_comparsion_type); ClassDB::bind_method(D_METHOD("set_comparison_type", "type"), &VisualShaderNodeCompare::set_comparison_type);
ClassDB::bind_method(D_METHOD("get_comparsion_type"), &VisualShaderNodeCompare::get_comparsion_type); ClassDB::bind_method(D_METHOD("get_comparison_type"), &VisualShaderNodeCompare::get_comparison_type);
ClassDB::bind_method(D_METHOD("set_function", "func"), &VisualShaderNodeCompare::set_function); ClassDB::bind_method(D_METHOD("set_function", "func"), &VisualShaderNodeCompare::set_function);
ClassDB::bind_method(D_METHOD("get_function"), &VisualShaderNodeCompare::get_function); ClassDB::bind_method(D_METHOD("get_function"), &VisualShaderNodeCompare::get_function);
@ -4001,7 +4001,7 @@ void VisualShaderNodeCompare::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_condition", "condition"), &VisualShaderNodeCompare::set_condition); ClassDB::bind_method(D_METHOD("set_condition", "condition"), &VisualShaderNodeCompare::set_condition);
ClassDB::bind_method(D_METHOD("get_condition"), &VisualShaderNodeCompare::get_condition); ClassDB::bind_method(D_METHOD("get_condition"), &VisualShaderNodeCompare::get_condition);
ADD_PROPERTY(PropertyInfo(Variant::INT, "type", PROPERTY_HINT_ENUM, "Scalar,Vector,Boolean,Transform"), "set_comparsion_type", "get_comparsion_type"); ADD_PROPERTY(PropertyInfo(Variant::INT, "type", PROPERTY_HINT_ENUM, "Scalar,Vector,Boolean,Transform"), "set_comparison_type", "get_comparison_type");
ADD_PROPERTY(PropertyInfo(Variant::INT, "function", PROPERTY_HINT_ENUM, "a == b,a != b,a > b,a >= b,a < b,a <= b"), "set_function", "get_function"); ADD_PROPERTY(PropertyInfo(Variant::INT, "function", PROPERTY_HINT_ENUM, "a == b,a != b,a > b,a >= b,a < b,a <= b"), "set_function", "get_function");
ADD_PROPERTY(PropertyInfo(Variant::INT, "condition", PROPERTY_HINT_ENUM, "All,Any"), "set_condition", "get_condition"); ADD_PROPERTY(PropertyInfo(Variant::INT, "condition", PROPERTY_HINT_ENUM, "All,Any"), "set_condition", "get_condition");

View file

@ -1635,7 +1635,7 @@ class VisualShaderNodeCompare : public VisualShaderNode {
GDCLASS(VisualShaderNodeCompare, VisualShaderNode); GDCLASS(VisualShaderNodeCompare, VisualShaderNode);
public: public:
enum ComparsionType { enum ComparisonType {
CTYPE_SCALAR, CTYPE_SCALAR,
CTYPE_VECTOR, CTYPE_VECTOR,
CTYPE_BOOLEAN, CTYPE_BOOLEAN,
@ -1657,7 +1657,7 @@ public:
}; };
protected: protected:
ComparsionType ctype; ComparisonType ctype;
Function func; Function func;
Condition condition; Condition condition;
@ -1677,8 +1677,8 @@ public:
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 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_comparsion_type(ComparsionType p_type); void set_comparison_type(ComparisonType p_type);
ComparsionType get_comparsion_type() const; ComparisonType get_comparison_type() const;
void set_function(Function p_func); void set_function(Function p_func);
Function get_function() const; Function get_function() const;
@ -1692,7 +1692,7 @@ public:
VisualShaderNodeCompare(); VisualShaderNodeCompare();
}; };
VARIANT_ENUM_CAST(VisualShaderNodeCompare::ComparsionType) VARIANT_ENUM_CAST(VisualShaderNodeCompare::ComparisonType)
VARIANT_ENUM_CAST(VisualShaderNodeCompare::Function) VARIANT_ENUM_CAST(VisualShaderNodeCompare::Function)
VARIANT_ENUM_CAST(VisualShaderNodeCompare::Condition) VARIANT_ENUM_CAST(VisualShaderNodeCompare::Condition)