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
path: root/intern
diff options
context:
space:
mode:
authorLukas Stockner <lukas.stockner@freenet.de>2018-05-24 03:51:41 +0300
committerLukas Stockner <lukas.stockner@freenet.de>2018-05-24 17:46:02 +0300
commit68627626854c27c2135cab72b48b648cb638c8cb (patch)
tree0add4728e9bc6d198c57721e59921844e8980f5e /intern
parent8d9faf840b8f99255b9989d178e5e4a6f5ec7f87 (diff)
Cycles/Compositor: Add arctan2 operation to the Math node
The Math node currently has the normal atan() function, but for actual angles this is fairly useless without additional nodes to handle the signs. Since the node has two inputs anyways, it only makes sense to add an arctan2 option. Reviewers: sergey, brecht Differential Revision: https://developer.blender.org/D3430
Diffstat (limited to 'intern')
-rw-r--r--intern/cycles/kernel/kernel_compat_opencl.h1
-rw-r--r--intern/cycles/kernel/shaders/node_math.osl2
-rw-r--r--intern/cycles/kernel/svm/svm_math_util.h2
-rw-r--r--intern/cycles/kernel/svm/svm_types.h1
-rw-r--r--intern/cycles/render/nodes.cpp1
5 files changed, 7 insertions, 0 deletions
diff --git a/intern/cycles/kernel/kernel_compat_opencl.h b/intern/cycles/kernel/kernel_compat_opencl.h
index 671c47e2225..ff7b69ab08f 100644
--- a/intern/cycles/kernel/kernel_compat_opencl.h
+++ b/intern/cycles/kernel/kernel_compat_opencl.h
@@ -116,6 +116,7 @@
#define asinf(x) asin(((float)(x)))
#define acosf(x) acos(((float)(x)))
#define atanf(x) atan(((float)(x)))
+#define atan2f(x, y) atan2(((float)(x)), ((float)(y)))
#define floorf(x) floor(((float)(x)))
#define ceilf(x) ceil(((float)(x)))
#define hypotf(x, y) hypot(((float)(x)), ((float)(y)))
diff --git a/intern/cycles/kernel/shaders/node_math.osl b/intern/cycles/kernel/shaders/node_math.osl
index f309ef7c6f3..c5fcbc311d3 100644
--- a/intern/cycles/kernel/shaders/node_math.osl
+++ b/intern/cycles/kernel/shaders/node_math.osl
@@ -95,6 +95,8 @@ shader node_math(
Value = safe_modulo(Value1, Value2);
else if (type == "absolute")
Value = fabs(Value1);
+ else if (type == "arctan2")
+ Value = atan2(Value1, Value2);
if (use_clamp)
Value = clamp(Value, 0.0, 1.0);
diff --git a/intern/cycles/kernel/svm/svm_math_util.h b/intern/cycles/kernel/svm/svm_math_util.h
index 1ce7777aac3..8e6bc73ddc7 100644
--- a/intern/cycles/kernel/svm/svm_math_util.h
+++ b/intern/cycles/kernel/svm/svm_math_util.h
@@ -92,6 +92,8 @@ ccl_device float svm_math(NodeMath type, float Fac1, float Fac2)
Fac = safe_modulo(Fac1, Fac2);
else if(type == NODE_MATH_ABSOLUTE)
Fac = fabsf(Fac1);
+ else if(type == NODE_MATH_ARCTAN2)
+ Fac = atan2f(Fac1, Fac2);
else if(type == NODE_MATH_CLAMP)
Fac = saturate(Fac1);
else
diff --git a/intern/cycles/kernel/svm/svm_types.h b/intern/cycles/kernel/svm/svm_types.h
index 4c3a5975fb8..dc62e25b340 100644
--- a/intern/cycles/kernel/svm/svm_types.h
+++ b/intern/cycles/kernel/svm/svm_types.h
@@ -259,6 +259,7 @@ typedef enum NodeMath {
NODE_MATH_GREATER_THAN,
NODE_MATH_MODULO,
NODE_MATH_ABSOLUTE,
+ NODE_MATH_ARCTAN2,
NODE_MATH_CLAMP /* used for the clamp UI option */
} NodeMath;
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp
index 01399c85bc0..c468924fa66 100644
--- a/intern/cycles/render/nodes.cpp
+++ b/intern/cycles/render/nodes.cpp
@@ -4953,6 +4953,7 @@ NODE_DEFINE(MathNode)
type_enum.insert("greater_than", NODE_MATH_GREATER_THAN);
type_enum.insert("modulo", NODE_MATH_MODULO);
type_enum.insert("absolute", NODE_MATH_ABSOLUTE);
+ type_enum.insert("arctan2", NODE_MATH_ARCTAN2);
SOCKET_ENUM(type, "Type", type_enum, NODE_MATH_ADD);
SOCKET_BOOLEAN(use_clamp, "Use Clamp", false);