mirror of
https://github.com/godotengine/godot.git
synced 2024-11-27 09:16:35 +08:00
Docs for some nodes in visual shader
Fix typo in `VisualShaderNodeCompare.ComparisonType` name.
This commit is contained in:
parent
c66144738b
commit
ce43c92208
@ -11,6 +11,7 @@
|
||||
<return type="Array">
|
||||
</return>
|
||||
<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>
|
||||
</method>
|
||||
<method name="get_input_port_default_value" qualifiers="const">
|
||||
@ -19,6 +20,7 @@
|
||||
<argument index="0" name="port" type="int">
|
||||
</argument>
|
||||
<description>
|
||||
Returns the default value of the input [code]port[/code].
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_default_input_values">
|
||||
@ -27,6 +29,7 @@
|
||||
<argument index="0" name="values" type="Array">
|
||||
</argument>
|
||||
<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>
|
||||
</method>
|
||||
<method name="set_input_port_default_value">
|
||||
@ -37,16 +40,19 @@
|
||||
<argument index="1" name="value" type="Variant">
|
||||
</argument>
|
||||
<description>
|
||||
Sets the default value for the selected input [code]port[/code].
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
<members>
|
||||
<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>
|
||||
</members>
|
||||
<signals>
|
||||
<signal name="editor_refresh_request">
|
||||
<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>
|
||||
</signal>
|
||||
</signals>
|
||||
|
@ -1,8 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualShaderNodeBooleanConstant" inherits="VisualShaderNode" category="Core" version="3.2">
|
||||
<brief_description>
|
||||
A boolean constant to be used within the visual shader graph.
|
||||
</brief_description>
|
||||
<description>
|
||||
Has only one output port and no inputs.
|
||||
Translated to [code]bool[/code] in the shader language.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
@ -10,6 +13,7 @@
|
||||
</methods>
|
||||
<members>
|
||||
<member name="constant" type="bool" setter="set_constant" getter="get_constant" default="false">
|
||||
A boolean constant which represents a state of this node.
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualShaderNodeBooleanUniform" inherits="VisualShaderNodeUniform" category="Core" version="3.2">
|
||||
<brief_description>
|
||||
A boolean uniform to be used within the visual shader graph.
|
||||
</brief_description>
|
||||
<description>
|
||||
Translated to [code]uniform bool[/code] in the shader language.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
|
@ -1,8 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualShaderNodeColorConstant" inherits="VisualShaderNode" category="Core" version="3.2">
|
||||
<brief_description>
|
||||
A [Color] constant to be used within the visual shader graph.
|
||||
</brief_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>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
@ -10,6 +13,7 @@
|
||||
</methods>
|
||||
<members>
|
||||
<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>
|
||||
</members>
|
||||
<constants>
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualShaderNodeColorFunc" inherits="VisualShaderNode" category="Core" version="3.2">
|
||||
<brief_description>
|
||||
A [Color] function to be used within the visual shader graph.
|
||||
</brief_description>
|
||||
<description>
|
||||
Accept a [Color] to the input port and transform it according to [member function].
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
@ -10,12 +12,29 @@
|
||||
</methods>
|
||||
<members>
|
||||
<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>
|
||||
</members>
|
||||
<constants>
|
||||
<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 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>
|
||||
</constants>
|
||||
</class>
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualShaderNodeColorOp" inherits="VisualShaderNode" category="Core" version="3.2">
|
||||
<brief_description>
|
||||
A [Color] operator to be used within the visual shader graph.
|
||||
</brief_description>
|
||||
<description>
|
||||
Applies [member operator] to two color inputs.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
@ -10,26 +12,87 @@
|
||||
</methods>
|
||||
<members>
|
||||
<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>
|
||||
</members>
|
||||
<constants>
|
||||
<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 name="OP_DIFFERENCE" value="1" enum="Operator">
|
||||
Produce a difference effect with the following formula:
|
||||
[codeblock]
|
||||
result = abs(a - b);
|
||||
[/codeblock]
|
||||
</constant>
|
||||
<constant name="OP_DARKEN" value="2" enum="Operator">
|
||||
Produce a darken effect with the following formula:
|
||||
[codeblock]
|
||||
result = min(a, b);
|
||||
[/codeblock]
|
||||
</constant>
|
||||
<constant name="OP_LIGHTEN" value="3" enum="Operator">
|
||||
Produce a lighten effect with the following formula:
|
||||
[codeblock]
|
||||
result = max(a, b);
|
||||
[/codeblock]
|
||||
</constant>
|
||||
<constant name="OP_OVERLAY" value="4" enum="Operator">
|
||||
Produce an overlay effect with the following formula:
|
||||
[codeblock]
|
||||
for (int i = 0; i < 3; i++) {
|
||||
float base = a[i];
|
||||
float blend = b[i];
|
||||
if (base < 0.5) {
|
||||
result[i] = 2.0 * base * blend;
|
||||
} else {
|
||||
result[i] = 1.0 - 2.0 * (1.0 - blend) * (1.0 - base);
|
||||
}
|
||||
}
|
||||
[/codeblock]
|
||||
</constant>
|
||||
<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 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 name="OP_SOFT_LIGHT" value="7" enum="Operator">
|
||||
Produce a soft light effect with the following formula:
|
||||
[codeblock]
|
||||
for (int i = 0; i < 3; i++) {
|
||||
float base = a[i];
|
||||
float blend = b[i];
|
||||
if (base < 0.5) {
|
||||
result[i] = base * (blend + 0.5);
|
||||
} else {
|
||||
result[i] = 1.0 - (1.0 - base) * (1.0 - (blend - 0.5));
|
||||
}
|
||||
}
|
||||
[/codeblock]
|
||||
</constant>
|
||||
<constant name="OP_HARD_LIGHT" value="8" enum="Operator">
|
||||
Produce a hard light effect with the following formula:
|
||||
[codeblock]
|
||||
for (int i = 0; i < 3; i++) {
|
||||
float base = a[i];
|
||||
float blend = b[i];
|
||||
if (base < 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>
|
||||
</constants>
|
||||
</class>
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualShaderNodeColorUniform" inherits="VisualShaderNodeUniform" category="Core" version="3.2">
|
||||
<brief_description>
|
||||
A [Color] uniform to be used within the visual shader graph.
|
||||
</brief_description>
|
||||
<description>
|
||||
Translated to [code]uniform vec4[/code] in the shader language.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualShaderNodeCompare" inherits="VisualShaderNode" category="Core" version="3.2">
|
||||
<brief_description>
|
||||
A comparison function for common types within the visual shader graph.
|
||||
</brief_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>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
@ -10,36 +12,51 @@
|
||||
</methods>
|
||||
<members>
|
||||
<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 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 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>
|
||||
</members>
|
||||
<constants>
|
||||
<constant name="CTYPE_SCALAR" value="0" enum="ComparsionType">
|
||||
<constant name="CTYPE_SCALAR" value="0" enum="ComparisonType">
|
||||
A floating-point scalar.
|
||||
</constant>
|
||||
<constant name="CTYPE_VECTOR" value="1" enum="ComparsionType">
|
||||
<constant name="CTYPE_VECTOR" value="1" enum="ComparisonType">
|
||||
A 3D vector type.
|
||||
</constant>
|
||||
<constant name="CTYPE_BOOLEAN" value="2" enum="ComparsionType">
|
||||
<constant name="CTYPE_BOOLEAN" value="2" enum="ComparisonType">
|
||||
A boolean type.
|
||||
</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 name="FUNC_EQUAL" value="0" enum="Function">
|
||||
Comparison for equality ([code]a == b[/code]).
|
||||
</constant>
|
||||
<constant name="FUNC_NOT_EQUAL" value="1" enum="Function">
|
||||
Comparison for inequality ([code]a != b[/code]).
|
||||
</constant>
|
||||
<constant name="FUNC_GREATER_THAN" value="2" enum="Function">
|
||||
Comparison for greater than ([code]a > b[/code]). Cannot be used if [member type] set to [constant CTYPE_BOOLEAN] or [constant CTYPE_TRANSFORM].
|
||||
</constant>
|
||||
<constant name="FUNC_GREATER_THAN_EQUAL" value="3" enum="Function">
|
||||
Comparison for greater than or equal ([code]a >= b[/code]). Cannot be used if [member type] set to [constant CTYPE_BOOLEAN] or [constant CTYPE_TRANSFORM].
|
||||
</constant>
|
||||
<constant name="FUNC_LESS_THAN" value="4" enum="Function">
|
||||
Comparison for less than ([code]a < b[/code]). Cannot be used if [member type] set to [constant CTYPE_BOOLEAN] or [constant CTYPE_TRANSFORM].
|
||||
</constant>
|
||||
<constant name="FUNC_LESS_THAN_EQUAL" value="5" enum="Function">
|
||||
Comparison for less than or equal ([code]a < b[/code]). Cannot be used if [member type] set to [constant CTYPE_BOOLEAN] or [constant CTYPE_TRANSFORM].
|
||||
</constant>
|
||||
<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 name="COND_ANY" value="1" enum="Condition">
|
||||
The result will be true if any of component in vector satisfy the comparison condition.
|
||||
</constant>
|
||||
</constants>
|
||||
</class>
|
||||
|
@ -3929,7 +3929,7 @@ String VisualShaderNodeCompare::generate_code(Shader::Mode p_mode, VisualShader:
|
||||
return code;
|
||||
}
|
||||
|
||||
void VisualShaderNodeCompare::set_comparsion_type(ComparsionType p_type) {
|
||||
void VisualShaderNodeCompare::set_comparison_type(ComparisonType p_type) {
|
||||
|
||||
ctype = p_type;
|
||||
|
||||
@ -3954,7 +3954,7 @@ void VisualShaderNodeCompare::set_comparsion_type(ComparsionType p_type) {
|
||||
emit_changed();
|
||||
}
|
||||
|
||||
VisualShaderNodeCompare::ComparsionType VisualShaderNodeCompare::get_comparsion_type() const {
|
||||
VisualShaderNodeCompare::ComparisonType VisualShaderNodeCompare::get_comparison_type() const {
|
||||
|
||||
return ctype;
|
||||
}
|
||||
@ -3992,8 +3992,8 @@ Vector<StringName> VisualShaderNodeCompare::get_editable_properties() const {
|
||||
|
||||
void VisualShaderNodeCompare::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_comparsion_type", "type"), &VisualShaderNodeCompare::set_comparsion_type);
|
||||
ClassDB::bind_method(D_METHOD("get_comparsion_type"), &VisualShaderNodeCompare::get_comparsion_type);
|
||||
ClassDB::bind_method(D_METHOD("set_comparison_type", "type"), &VisualShaderNodeCompare::set_comparison_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("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("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, "condition", PROPERTY_HINT_ENUM, "All,Any"), "set_condition", "get_condition");
|
||||
|
||||
|
@ -1635,7 +1635,7 @@ class VisualShaderNodeCompare : public VisualShaderNode {
|
||||
GDCLASS(VisualShaderNodeCompare, VisualShaderNode);
|
||||
|
||||
public:
|
||||
enum ComparsionType {
|
||||
enum ComparisonType {
|
||||
CTYPE_SCALAR,
|
||||
CTYPE_VECTOR,
|
||||
CTYPE_BOOLEAN,
|
||||
@ -1657,7 +1657,7 @@ public:
|
||||
};
|
||||
|
||||
protected:
|
||||
ComparsionType ctype;
|
||||
ComparisonType ctype;
|
||||
Function func;
|
||||
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
|
||||
|
||||
void set_comparsion_type(ComparsionType p_type);
|
||||
ComparsionType get_comparsion_type() const;
|
||||
void set_comparison_type(ComparisonType p_type);
|
||||
ComparisonType get_comparison_type() const;
|
||||
|
||||
void set_function(Function p_func);
|
||||
Function get_function() const;
|
||||
@ -1692,7 +1692,7 @@ public:
|
||||
VisualShaderNodeCompare();
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(VisualShaderNodeCompare::ComparsionType)
|
||||
VARIANT_ENUM_CAST(VisualShaderNodeCompare::ComparisonType)
|
||||
VARIANT_ENUM_CAST(VisualShaderNodeCompare::Function)
|
||||
VARIANT_ENUM_CAST(VisualShaderNodeCompare::Condition)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user