diff --git a/doc/classes/VisualShaderNode.xml b/doc/classes/VisualShaderNode.xml
index 9f7e4573ff7..185c5dab905 100644
--- a/doc/classes/VisualShaderNode.xml
+++ b/doc/classes/VisualShaderNode.xml
@@ -11,6 +11,7 @@
+ Returns an [Array] containing default values for all of the input ports of the node in the form [code][index0, value0, index1, value1, ...][/code].
@@ -19,6 +20,7 @@
+ Returns the default value of the input [code]port[/code].
@@ -27,6 +29,7 @@
+ 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].
@@ -37,16 +40,19 @@
+ Sets the default value for the selected input [code]port[/code].
+ Sets the output port index which will be showed for preview. If set to [code]-1[/code] no port will be open for preview.
+ Emitted when the node requests an editor refresh. Currently called only in setter of [member VisualShaderNodeTexture.source], [VisualShaderNodeTexture], and [VisualShaderNodeCubeMap] (and their derivatives).
diff --git a/doc/classes/VisualShaderNodeBooleanConstant.xml b/doc/classes/VisualShaderNodeBooleanConstant.xml
index b46905cfeae..aba2f639612 100644
--- a/doc/classes/VisualShaderNodeBooleanConstant.xml
+++ b/doc/classes/VisualShaderNodeBooleanConstant.xml
@@ -1,8 +1,11 @@
+ A boolean constant to be used within the visual shader graph.
+ Has only one output port and no inputs.
+ Translated to [code]bool[/code] in the shader language.
@@ -10,6 +13,7 @@
+ A boolean constant which represents a state of this node.
diff --git a/doc/classes/VisualShaderNodeBooleanUniform.xml b/doc/classes/VisualShaderNodeBooleanUniform.xml
index 518c7ba3b83..f00f2031c7d 100644
--- a/doc/classes/VisualShaderNodeBooleanUniform.xml
+++ b/doc/classes/VisualShaderNodeBooleanUniform.xml
@@ -1,8 +1,10 @@
+ A boolean uniform to be used within the visual shader graph.
+ Translated to [code]uniform bool[/code] in the shader language.
diff --git a/doc/classes/VisualShaderNodeColorConstant.xml b/doc/classes/VisualShaderNodeColorConstant.xml
index 282966a9ca4..333bfccf995 100644
--- a/doc/classes/VisualShaderNodeColorConstant.xml
+++ b/doc/classes/VisualShaderNodeColorConstant.xml
@@ -1,8 +1,11 @@
+ A [Color] constant to be used within the visual shader graph.
+ 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.
@@ -10,6 +13,7 @@
+ A [Color] constant which represents a state of this node.
diff --git a/doc/classes/VisualShaderNodeColorFunc.xml b/doc/classes/VisualShaderNodeColorFunc.xml
index b37a669ee9f..9e8e13245be 100644
--- a/doc/classes/VisualShaderNodeColorFunc.xml
+++ b/doc/classes/VisualShaderNodeColorFunc.xml
@@ -1,8 +1,10 @@
+ A [Color] function to be used within the visual shader graph.
+ Accept a [Color] to the input port and transform it according to [member function].
@@ -10,12 +12,29 @@
+ A function to be applied to the input color. See [enum Function] for options.
+ 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]
+ 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]
diff --git a/doc/classes/VisualShaderNodeColorOp.xml b/doc/classes/VisualShaderNodeColorOp.xml
index 77c5361f4dc..414de2ed5a0 100644
--- a/doc/classes/VisualShaderNodeColorOp.xml
+++ b/doc/classes/VisualShaderNodeColorOp.xml
@@ -1,8 +1,10 @@
+ A [Color] operator to be used within the visual shader graph.
+ Applies [member operator] to two color inputs.
@@ -10,26 +12,87 @@
+ An operator to be applied to the inputs. See [enum Operator] for options.
+ Produce a screen effect with the following formula:
+ [codeblock]
+ result = vec3(1.0) - (vec3(1.0) - a) * (vec3(1.0) - b);
+ [/codeblock]
+ Produce a difference effect with the following formula:
+ [codeblock]
+ result = abs(a - b);
+ [/codeblock]
+ Produce a darken effect with the following formula:
+ [codeblock]
+ result = min(a, b);
+ [/codeblock]
+ Produce a lighten effect with the following formula:
+ [codeblock]
+ result = max(a, b);
+ [/codeblock]
+ 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]
+ Produce a dodge effect with the following formula:
+ [codeblock]
+ result = a / (vec3(1.0) - b);
+ [/codeblock]
+ Produce a burn effect with the following formula:
+ [codeblock]
+ result = vec3(1.0) - (vec3(1.0) - a) / b;
+ [/codeblock]
+ 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]
+ 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]
diff --git a/doc/classes/VisualShaderNodeColorUniform.xml b/doc/classes/VisualShaderNodeColorUniform.xml
index ec61729782d..7d07aa00512 100644
--- a/doc/classes/VisualShaderNodeColorUniform.xml
+++ b/doc/classes/VisualShaderNodeColorUniform.xml
@@ -1,8 +1,10 @@
+ A [Color] uniform to be used within the visual shader graph.
+ Translated to [code]uniform vec4[/code] in the shader language.
diff --git a/doc/classes/VisualShaderNodeCompare.xml b/doc/classes/VisualShaderNodeCompare.xml
index 7edad5294dc..3eaa1399b15 100644
--- a/doc/classes/VisualShaderNodeCompare.xml
+++ b/doc/classes/VisualShaderNodeCompare.xml
@@ -1,8 +1,10 @@
+ A comparison function for common types within the visual shader graph.
+ 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.
@@ -10,36 +12,51 @@
+ Extra condition which is applied if [member type] is set to [constant CTYPE_VECTOR].
+ A comparison function. See [enum Function] for options.
-
+
+ The type to be used in the comparison. See [enum ComparisonType] for options.
-
+
+ A floating-point scalar.
-
+
+ A 3D vector type.
-
+
+ A boolean type.
-
+
+ A transform ([code]mat4[/code]) type.
+ Comparison for equality ([code]a == b[/code]).
+ Comparison for inequality ([code]a != b[/code]).
+ Comparison for greater than ([code]a > b[/code]). Cannot be used if [member type] set to [constant CTYPE_BOOLEAN] or [constant CTYPE_TRANSFORM].
+ 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].
+ Comparison for less than ([code]a < b[/code]). Cannot be used if [member type] set to [constant CTYPE_BOOLEAN] or [constant CTYPE_TRANSFORM].
+ 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].
+ The result will be true if all of component in vector satisfy the comparison condition.
+ The result will be true if any of component in vector satisfy the comparison condition.
diff --git a/scene/resources/visual_shader_nodes.cpp b/scene/resources/visual_shader_nodes.cpp
index f46fba3b5b0..225274a5feb 100644
--- a/scene/resources/visual_shader_nodes.cpp
+++ b/scene/resources/visual_shader_nodes.cpp
@@ -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 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");
diff --git a/scene/resources/visual_shader_nodes.h b/scene/resources/visual_shader_nodes.h
index 0f428088e06..cca37273d94 100644
--- a/scene/resources/visual_shader_nodes.h
+++ b/scene/resources/visual_shader_nodes.h
@@ -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)