diff options
author | Charlie Jolly <charlie> | 2020-02-17 18:15:46 +0300 |
---|---|---|
committer | Charlie Jolly <mistajolly@gmail.com> | 2020-02-17 18:43:18 +0300 |
commit | 20a4cdfd700d3722fdcaa3b3952ccea1b0e6ee47 (patch) | |
tree | 16eee69e8e1d3bdfb902e05df15b055f7141fd4d /intern/cycles/render/nodes.cpp | |
parent | ab3a6e050c856345d10f8e36155913288559e4dc (diff) |
Cycles: Vector Rotate Node using Axis and Angle method
This node provides the ability to rotate a vector around a `center` point using either `Axis Angle` , `Single Axis` or `Euler` methods.
Reviewed By: #cycles, brecht
Differential Revision: https://developer.blender.org/D3789
Diffstat (limited to 'intern/cycles/render/nodes.cpp')
-rw-r--r-- | intern/cycles/render/nodes.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index 83b973011a1..41b4b05ba19 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -6131,6 +6131,64 @@ void VectorMathNode::compile(OSLCompiler &compiler) compiler.add(this, "node_vector_math"); } +/* Vector Rotate */ + +NODE_DEFINE(VectorRotateNode) +{ + NodeType *type = NodeType::add("vector_rotate", create, NodeType::SHADER); + + static NodeEnum type_enum; + type_enum.insert("axis", NODE_VECTOR_ROTATE_TYPE_AXIS); + type_enum.insert("x_axis", NODE_VECTOR_ROTATE_TYPE_AXIS_X); + type_enum.insert("y_axis", NODE_VECTOR_ROTATE_TYPE_AXIS_Y); + type_enum.insert("z_axis", NODE_VECTOR_ROTATE_TYPE_AXIS_Z); + type_enum.insert("euler_xyz", NODE_VECTOR_ROTATE_TYPE_EULER_XYZ); + type_enum.insert("euler_xzy", NODE_VECTOR_ROTATE_TYPE_EULER_XZY); + type_enum.insert("euler_yxz", NODE_VECTOR_ROTATE_TYPE_EULER_YXZ); + type_enum.insert("euler_yzx", NODE_VECTOR_ROTATE_TYPE_EULER_YZX); + type_enum.insert("euler_zxy", NODE_VECTOR_ROTATE_TYPE_EULER_ZXY); + type_enum.insert("euler_zyx", NODE_VECTOR_ROTATE_TYPE_EULER_ZYX); + SOCKET_ENUM(type, "Type", type_enum, NODE_VECTOR_ROTATE_TYPE_AXIS); + + SOCKET_IN_VECTOR(vector, "Vector", make_float3(0.0f, 0.0f, 0.0f)); + SOCKET_IN_POINT(rotation, "Rotation", make_float3(0.0f, 0.0f, 0.0f)); + SOCKET_IN_POINT(center, "Center", make_float3(0.0f, 0.0f, 0.0f)); + SOCKET_IN_VECTOR(axis, "Axis", make_float3(0.0f, 0.0f, 1.0f)); + SOCKET_IN_FLOAT(angle, "Angle", 0.0f); + SOCKET_OUT_VECTOR(vector, "Vector"); + + return type; +} + +VectorRotateNode::VectorRotateNode() : ShaderNode(node_type) +{ +} + +void VectorRotateNode::compile(SVMCompiler &compiler) +{ + ShaderInput *vector_in = input("Vector"); + ShaderInput *rotation_in = input("Rotation"); + ShaderInput *center_in = input("Center"); + ShaderInput *axis_in = input("Axis"); + ShaderInput *angle_in = input("Angle"); + ShaderOutput *vector_out = output("Vector"); + + compiler.add_node(NODE_VECTOR_ROTATE, + compiler.encode_uchar4(type, + compiler.stack_assign(vector_in), + compiler.stack_assign(rotation_in)), + compiler.encode_uchar4(compiler.stack_assign(center_in), + compiler.stack_assign(axis_in), + compiler.stack_assign(angle_in)), + compiler.stack_assign(vector_out)); +} + +void VectorRotateNode::compile(OSLCompiler &compiler) +{ + compiler.parameter(this, "type"); + compiler.add(this, "node_vector_rotate"); +} + /* VectorTransform */ NODE_DEFINE(VectorTransformNode) |