diff options
author | Charlie Jolly <charlie> | 2020-02-15 00:46:10 +0300 |
---|---|---|
committer | Charlie Jolly <mistajolly@gmail.com> | 2020-02-15 01:14:05 +0300 |
commit | 635ab9d1dded4d4975bd4486718fde19e8e901ca (patch) | |
tree | 63ae9c050c4749212c2beed2e0e46d9bc14b6c72 /intern/cycles/kernel/svm | |
parent | 44d7706fe1868d66e8e724aebd9c3841cca67794 (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/kernel/svm')
-rw-r--r-- | intern/cycles/kernel/svm/svm_math.h | 10 | ||||
-rw-r--r-- | intern/cycles/kernel/svm/svm_math_util.h | 15 | ||||
-rw-r--r-- | intern/cycles/kernel/svm/svm_types.h | 4 |
3 files changed, 27 insertions, 2 deletions
diff --git a/intern/cycles/kernel/svm/svm_math.h b/intern/cycles/kernel/svm/svm_math.h index 82cae7bbacf..01e01c399ea 100644 --- a/intern/cycles/kernel/svm/svm_math.h +++ b/intern/cycles/kernel/svm/svm_math.h @@ -51,11 +51,19 @@ ccl_device void svm_node_vector_math(KernelGlobals *kg, float3 a = stack_load_float3(stack, a_stack_offset); float3 b = stack_load_float3(stack, b_stack_offset); + float3 c; float scale = stack_load_float(stack, scale_stack_offset); float value; float3 vector; - svm_vector_math(&value, &vector, (NodeVectorMathType)type, a, b, scale); + + /* 3 Vector Operators */ + if (type == NODE_VECTOR_MATH_WRAP) { + uint4 extra_node = read_node(kg, offset); + c = stack_load_float3(stack, extra_node.x); + } + + svm_vector_math(&value, &vector, (NodeVectorMathType)type, a, b, c, scale); if (stack_valid(value_stack_offset)) stack_store_float(stack, value_stack_offset, value); diff --git a/intern/cycles/kernel/svm/svm_math_util.h b/intern/cycles/kernel/svm/svm_math_util.h index 7b9eaaeb710..8b431b54eea 100644 --- a/intern/cycles/kernel/svm/svm_math_util.h +++ b/intern/cycles/kernel/svm/svm_math_util.h @@ -17,7 +17,7 @@ CCL_NAMESPACE_BEGIN ccl_device void svm_vector_math( - float *value, float3 *vector, NodeVectorMathType type, float3 a, float3 b, float scale) + float *value, float3 *vector, NodeVectorMathType type, float3 a, float3 b, float3 c, float scale) { switch (type) { case NODE_VECTOR_MATH_ADD: @@ -68,6 +68,10 @@ ccl_device void svm_vector_math( case NODE_VECTOR_MATH_MODULO: *vector = make_float3(safe_modulo(a.x, b.x), safe_modulo(a.y, b.y), safe_modulo(a.z, b.z)); break; + case NODE_VECTOR_MATH_WRAP: + *vector = make_float3( + wrapf(a.x, b.x, c.x), wrapf(a.y, b.y, c.y), wrapf(a.z, b.z, c.z)); + break; case NODE_VECTOR_MATH_FRACTION: *vector = a - floor(a); break; @@ -80,6 +84,15 @@ ccl_device void svm_vector_math( case NODE_VECTOR_MATH_MAXIMUM: *vector = max(a, b); break; + case NODE_VECTOR_MATH_SINE: + *vector = make_float3(sinf(a.x), sinf(a.y), sinf(a.z)); + break; + case NODE_VECTOR_MATH_COSINE: + *vector = make_float3(cosf(a.x), cosf(a.y), cosf(a.z)); + break; + case NODE_VECTOR_MATH_TANGENT: + *vector = make_float3(tanf(a.x), tanf(a.y), tanf(a.z)); + break; default: *vector = make_float3(0.0f, 0.0f, 0.0f); *value = 0.0f; diff --git a/intern/cycles/kernel/svm/svm_types.h b/intern/cycles/kernel/svm/svm_types.h index 8dbb147e76a..828b43eb8e4 100644 --- a/intern/cycles/kernel/svm/svm_types.h +++ b/intern/cycles/kernel/svm/svm_types.h @@ -326,6 +326,10 @@ typedef enum NodeVectorMathType { NODE_VECTOR_MATH_ABSOLUTE, NODE_VECTOR_MATH_MINIMUM, NODE_VECTOR_MATH_MAXIMUM, + NODE_VECTOR_MATH_WRAP, + NODE_VECTOR_MATH_SINE, + NODE_VECTOR_MATH_COSINE, + NODE_VECTOR_MATH_TANGENT, } NodeVectorMathType; typedef enum NodeClampType { |