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>2020-02-15 00:46:10 +0300
committerCharlie Jolly <mistajolly@gmail.com>2020-02-15 01:14:05 +0300
commit635ab9d1dded4d4975bd4486718fde19e8e901ca (patch)
tree63ae9c050c4749212c2beed2e0e46d9bc14b6c72 /intern/cycles/render/nodes.cpp
parent44d7706fe1868d66e8e724aebd9c3841cca67794 (diff)
Shading: Extend Vector Math Node with Sin, Cos, Tan and Wrap functions
This adds some extra functions recently added to the float Maths Node. Not all functions have been ported over in this patch. Also: + Tidy up menu + Change node color to match other vector nodes, this helps distinguish vector and float nodes in the tree + Move shared OSL functions to new header node_math.h Reviewed By: brecht Differential Revision: https://developer.blender.org/D6713
Diffstat (limited to 'intern/cycles/render/nodes.cpp')
-rw-r--r--intern/cycles/render/nodes.cpp31
1 files changed, 25 insertions, 6 deletions
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp
index 75e21e00dcf..3f5c2aacc98 100644
--- a/intern/cycles/render/nodes.cpp
+++ b/intern/cycles/render/nodes.cpp
@@ -6022,14 +6022,20 @@ NODE_DEFINE(VectorMathNode)
type_enum.insert("floor", NODE_VECTOR_MATH_FLOOR);
type_enum.insert("ceil", NODE_VECTOR_MATH_CEIL);
type_enum.insert("modulo", NODE_VECTOR_MATH_MODULO);
+ type_enum.insert("wrap", NODE_VECTOR_MATH_WRAP);
type_enum.insert("fraction", NODE_VECTOR_MATH_FRACTION);
type_enum.insert("absolute", NODE_VECTOR_MATH_ABSOLUTE);
type_enum.insert("minimum", NODE_VECTOR_MATH_MINIMUM);
type_enum.insert("maximum", NODE_VECTOR_MATH_MAXIMUM);
+
+ type_enum.insert("sine", NODE_VECTOR_MATH_SINE);
+ type_enum.insert("cosine", NODE_VECTOR_MATH_COSINE);
+ type_enum.insert("tangent", NODE_VECTOR_MATH_TANGENT);
SOCKET_ENUM(type, "Type", type_enum, NODE_VECTOR_MATH_ADD);
SOCKET_IN_VECTOR(vector1, "Vector1", make_float3(0.0f, 0.0f, 0.0f));
SOCKET_IN_VECTOR(vector2, "Vector2", make_float3(0.0f, 0.0f, 0.0f));
+ SOCKET_IN_VECTOR(vector3, "Vector3", make_float3(0.0f, 0.0f, 0.0f));
SOCKET_IN_FLOAT(scale, "Scale", 1.0f);
SOCKET_OUT_FLOAT(value, "Value");
@@ -6048,7 +6054,7 @@ void VectorMathNode::constant_fold(const ConstantFolder &folder)
float3 vector = make_float3(0.0f, 0.0f, 0.0f);
if (folder.all_inputs_constant()) {
- svm_vector_math(&value, &vector, type, vector1, vector2, scale);
+ svm_vector_math(&value, &vector, type, vector1, vector2, vector3, scale);
if (folder.output == output("Value")) {
folder.make_constant(value);
}
@@ -6075,11 +6081,24 @@ void VectorMathNode::compile(SVMCompiler &compiler)
int value_stack_offset = compiler.stack_assign_if_linked(value_out);
int vector_stack_offset = compiler.stack_assign_if_linked(vector_out);
- compiler.add_node(
- NODE_VECTOR_MATH,
- type,
- compiler.encode_uchar4(vector1_stack_offset, vector2_stack_offset, scale_stack_offset),
- compiler.encode_uchar4(value_stack_offset, vector_stack_offset));
+ /* 3 Vector Operators */
+ if (type == NODE_VECTOR_MATH_WRAP) {
+ ShaderInput *vector3_in = input("Vector3");
+ int vector3_stack_offset = compiler.stack_assign(vector3_in);
+ compiler.add_node(
+ NODE_VECTOR_MATH,
+ type,
+ compiler.encode_uchar4(vector1_stack_offset, vector2_stack_offset, scale_stack_offset),
+ compiler.encode_uchar4(value_stack_offset, vector_stack_offset));
+ compiler.add_node(vector3_stack_offset);
+ }
+ else {
+ compiler.add_node(
+ NODE_VECTOR_MATH,
+ type,
+ compiler.encode_uchar4(vector1_stack_offset, vector2_stack_offset, scale_stack_offset),
+ compiler.encode_uchar4(value_stack_offset, vector_stack_offset));
+ }
}
void VectorMathNode::compile(OSLCompiler &compiler)