Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharlie Jolly <charlie>2019-12-06 02:02:05 +0300
committerCharlie Jolly <mistajolly@gmail.com>2019-12-07 15:33:07 +0300
commit0406eb110332a863811d7fb6228f9a7ca514e022 (patch)
tree9809062966699e31c785ae0dc97ccb6e9f6c60f7 /source/blender/makesrna/intern/rna_nodetree.c
parent6a78ace569ec7c0e076e5af34d9496ce3363b81e (diff)
Maths Node: Additional functions
When creating shaders and using maths functions it is expected that Blender should match functions in other DCC applications, game engines and shading languages such as GLSL and OSL. This patch adds missing functions to the Blender maths node. Ideally, it would be nice to have these functions available to vectors too but that is not part of this patch. This patch adds the following functions trunc, snap, wrap, compare, pingpong, sign, radians, degrees, cosh, sinh, tanh, exp, smoothmin and inversesqrt. Sign function is based on GLSL and OSL functions and returns zero when x == 0. Differential Revision: https://developer.blender.org/D5957
Diffstat (limited to 'source/blender/makesrna/intern/rna_nodetree.c')
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c39
1 files changed, 36 insertions, 3 deletions
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 287c7502c41..272a4522152 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -123,21 +123,37 @@ const EnumPropertyItem rna_enum_mapping_type_items[] = {
};
const EnumPropertyItem rna_enum_node_math_items[] = {
+ {0, "", 0, N_("Functions"), ""},
{NODE_MATH_ADD, "ADD", 0, "Add", "A + B"},
{NODE_MATH_SUBTRACT, "SUBTRACT", 0, "Subtract", "A - B"},
{NODE_MATH_MULTIPLY, "MULTIPLY", 0, "Multiply", "A * B"},
{NODE_MATH_DIVIDE, "DIVIDE", 0, "Divide", "A / B"},
+ {NODE_MATH_MULTIPLY_ADD, "MULTIPLY_ADD", 0, "Multiply Add", "A * B + C"},
{0, "", ICON_NONE, NULL, NULL},
{NODE_MATH_POWER, "POWER", 0, "Power", "A power B"},
{NODE_MATH_LOGARITHM, "LOGARITHM", 0, "Logarithm", "Logarithm A base B"},
{NODE_MATH_SQRT, "SQRT", 0, "Square Root", "Square root of A"},
+ {NODE_MATH_INV_SQRT, "INVERSE_SQRT", 0, "Inverse Square Root", "1 / Square root of A"},
{NODE_MATH_ABSOLUTE, "ABSOLUTE", 0, "Absolute", "Magnitude of A"},
- {0, "", ICON_NONE, NULL, NULL},
+ {NODE_MATH_EXPONENT, "EXPONENT", 0, "Exponent", "exp(A)"},
+ {0, "", 0, N_("Comparison"), ""},
{NODE_MATH_MINIMUM, "MINIMUM", 0, "Minimum", "The minimum from A and B"},
{NODE_MATH_MAXIMUM, "MAXIMUM", 0, "Maximum", "The maximum from A and B"},
{NODE_MATH_LESS_THAN, "LESS_THAN", 0, "Less Than", "1 if A < B else 0"},
{NODE_MATH_GREATER_THAN, "GREATER_THAN", 0, "Greater Than", "1 if A > B else 0"},
- {0, "", ICON_NONE, NULL, NULL},
+ {NODE_MATH_SIGN, "SIGN", 0, "Sign", "Returns the sign of A"},
+ {NODE_MATH_COMPARE, "COMPARE", 0, "Compare", "1 if (A == B) within tolerance C else 0"},
+ {NODE_MATH_SMOOTH_MIN,
+ "SMOOTH_MIN",
+ 0,
+ "Smooth Minimum",
+ "The minimum from A and B with smoothing C"},
+ {NODE_MATH_SMOOTH_MAX,
+ "SMOOTH_MAX",
+ 0,
+ "Smooth Maximum",
+ "The maximum from A and B with smoothing C"},
+ {0, "", 0, N_("Rounding"), ""},
{NODE_MATH_ROUND,
"ROUND",
0,
@@ -145,16 +161,33 @@ const EnumPropertyItem rna_enum_node_math_items[] = {
"Round A to the nearest integer. Round upward if the fraction part is 0.5"},
{NODE_MATH_FLOOR, "FLOOR", 0, "Floor", "The largest integer smaller than or equal A"},
{NODE_MATH_CEIL, "CEIL", 0, "Ceil", "The smallest integer greater than or equal A"},
+ {NODE_MATH_TRUNC, "TRUNC", 0, "Truncate", "trunc(A)"},
+ {0, "", ICON_NONE, NULL, NULL},
{NODE_MATH_FRACTION, "FRACT", 0, "Fraction", "The fraction part of A"},
{NODE_MATH_MODULO, "MODULO", 0, "Modulo", "A mod B"},
- {0, "", ICON_NONE, NULL, NULL},
+ {NODE_MATH_SNAP, "SNAP", 0, "Snap", "Snap to increment, snap(A,B)"},
+ {NODE_MATH_WRAP, "WRAP", 0, "Wrap", "Wrap value to range, wrap(A,B)"},
+ {NODE_MATH_PINGPONG,
+ "PINGPONG",
+ 0,
+ "Pingpong",
+ "Wraps a value and reverses every other cycle (A,B)"},
+ {0, "", 0, N_("Trigonometric"), ""},
{NODE_MATH_SINE, "SINE", 0, "Sine", "sin(A)"},
{NODE_MATH_COSINE, "COSINE", 0, "Cosine", "cos(A)"},
{NODE_MATH_TANGENT, "TANGENT", 0, "Tangent", "tan(A)"},
+ {0, "", ICON_NONE, NULL, NULL},
{NODE_MATH_ARCSINE, "ARCSINE", 0, "Arcsine", "arcsin(A)"},
{NODE_MATH_ARCCOSINE, "ARCCOSINE", 0, "Arccosine", "arccos(A)"},
{NODE_MATH_ARCTANGENT, "ARCTANGENT", 0, "Arctangent", "arctan(A)"},
{NODE_MATH_ARCTAN2, "ARCTAN2", 0, "Arctan2", "The signed angle arctan(A / B)"},
+ {0, "", ICON_NONE, NULL, NULL},
+ {NODE_MATH_SINH, "SINH", 0, "Hyperbolic Sine", "sinh(A)"},
+ {NODE_MATH_COSH, "COSH", 0, "Hyperbolic Cosine", "cosh(A)"},
+ {NODE_MATH_TANH, "TANH", 0, "Hyperbolic Tangent", "tanh(A)"},
+ {0, "", 0, N_("Conversion"), ""},
+ {NODE_MATH_RADIANS, "RADIANS", 0, "To Radians", "Convert from degrees to radians"},
+ {NODE_MATH_DEGREES, "DEGREES", 0, "To Degrees", "Convert from radians to degrees"},
{0, NULL, 0, NULL, NULL},
};