diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2012-08-30 10:31:02 +0400 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2012-08-30 10:31:02 +0400 |
commit | ded5e9cd2324eaa28b85d17d0f8d394f72625c8a (patch) | |
tree | eb3d9815e55a3ad8b66e5bf4a8c0b9cf26416c93 /intern/cycles/kernel/svm/svm_mix.h | |
parent | 3f83d273b344221de5ec30c39c305ad5fa486f42 (diff) |
clamp for Mix node
the implementation was following my early commit for Math node
I haven't had a chance to run those through Brecht, but would like to do eventually. (they work fine though)
Diffstat (limited to 'intern/cycles/kernel/svm/svm_mix.h')
-rw-r--r-- | intern/cycles/kernel/svm/svm_mix.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/intern/cycles/kernel/svm/svm_mix.h b/intern/cycles/kernel/svm/svm_mix.h index 6b455e713c2..888e4d9645e 100644 --- a/intern/cycles/kernel/svm/svm_mix.h +++ b/intern/cycles/kernel/svm/svm_mix.h @@ -276,6 +276,17 @@ __device float3 svm_mix_linear(float t, float3 col1, float3 col2) return outcol; } +__device float3 svm_mix_clamp(float3 col) +{ + float3 outcol = col; + + outcol.x = clamp(col.x, 0.0f, 1.0f); + outcol.y = clamp(col.y, 0.0f, 1.0f); + outcol.z = clamp(col.z, 0.0f, 1.0f); + + return outcol; +} + __device float3 svm_mix(NodeMix type, float fac, float3 c1, float3 c2) { float t = clamp(fac, 0.0f, 1.0f); @@ -299,6 +310,7 @@ __device float3 svm_mix(NodeMix type, float fac, float3 c1, float3 c2) case NODE_MIX_COLOR: return svm_mix_color(t, c1, c2); case NODE_MIX_SOFT: return svm_mix_soft(t, c1, c2); case NODE_MIX_LINEAR: return svm_mix_linear(t, c1, c2); + case NODE_MIX_CLAMP: return svm_mix_clamp(c1); } return make_float3(0.0f, 0.0f, 0.0f); |