diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2012-08-29 21:30:14 +0400 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2012-08-29 21:30:14 +0400 |
commit | c052ebda8e13df7dfb662a4ebb9fd42fbe74d23e (patch) | |
tree | 5055fe630b240e0b68093045384cdf05535184d7 /intern/cycles/kernel | |
parent | 7a13bc2196336c4ec45e86947d9fcb0b8d61f74e (diff) |
Cycles bugfix: [32431] Cycles Math Node : Clamp does not work
the OSL solution is slightly different than the svm, but I think it's fine.
thanks Lukas Toenne for helping with a fix on the original patch
Diffstat (limited to 'intern/cycles/kernel')
-rw-r--r-- | intern/cycles/kernel/osl/nodes/node_math.osl | 4 | ||||
-rw-r--r-- | intern/cycles/kernel/svm/svm_math.h | 2 | ||||
-rw-r--r-- | intern/cycles/kernel/svm/svm_types.h | 3 |
3 files changed, 8 insertions, 1 deletions
diff --git a/intern/cycles/kernel/osl/nodes/node_math.osl b/intern/cycles/kernel/osl/nodes/node_math.osl index be9bb71d511..b62403600ff 100644 --- a/intern/cycles/kernel/osl/nodes/node_math.osl +++ b/intern/cycles/kernel/osl/nodes/node_math.osl @@ -40,6 +40,7 @@ float safe_log(float a, float b) shader node_math( string type = "Add", + int Clamp = false, float Value1 = 0.0, float Value2 = 0.0, output float Value = 0.0) @@ -80,5 +81,8 @@ shader node_math( Value = Value1 < Value2; if(type == "Greater Than") Value = Value1 > Value2; + + if(Clamp) + Value = clamp(Value1, 0.0, 1.0); } diff --git a/intern/cycles/kernel/svm/svm_math.h b/intern/cycles/kernel/svm/svm_math.h index bc2f774097e..e39c7a4ba6c 100644 --- a/intern/cycles/kernel/svm/svm_math.h +++ b/intern/cycles/kernel/svm/svm_math.h @@ -108,6 +108,8 @@ __device float svm_math(NodeMath type, float Fac1, float Fac2) Fac = Fac1 < Fac2; else if(type == NODE_MATH_GREATER_THAN) Fac = Fac1 > Fac2; + else if(type == NODE_MATH_CLAMP) + Fac = clamp(Fac1, 0.0f, 1.0f); else Fac = 0.0f; diff --git a/intern/cycles/kernel/svm/svm_types.h b/intern/cycles/kernel/svm/svm_types.h index cbff0c099ea..df06b883cae 100644 --- a/intern/cycles/kernel/svm/svm_types.h +++ b/intern/cycles/kernel/svm/svm_types.h @@ -183,7 +183,8 @@ typedef enum NodeMath { NODE_MATH_MAXIMUM, NODE_MATH_ROUND, NODE_MATH_LESS_THAN, - NODE_MATH_GREATER_THAN + NODE_MATH_GREATER_THAN, + NODE_MATH_CLAMP /* used for the clamp UI option */ } NodeMath; typedef enum NodeVectorMath { |