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
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2014-10-31 16:42:48 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2014-10-31 16:58:00 +0300
commitf9688d88ff528e94e0ac059c6fc41a163fb0f6be (patch)
tree35f9c5a3f7203af9a5678c438b47e821ac62c864 /intern/cycles/kernel/svm/svm_hsv.h
parenta6a3989617e680327bda2357fe506d86574e2618 (diff)
Fix T42391: HSV correction shader node gives negative values
This mainly happens when over-saturating already saturated color. After some discussion with Campbell and loads of tests we decided to clamp the result RGB color. As an alternative we might want to clamp corrected HSV values instead, but that would lead to some larger changes in the render results. TODO: The same is to be done for compositor nodes.
Diffstat (limited to 'intern/cycles/kernel/svm/svm_hsv.h')
-rw-r--r--intern/cycles/kernel/svm/svm_hsv.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/intern/cycles/kernel/svm/svm_hsv.h b/intern/cycles/kernel/svm/svm_hsv.h
index 11dfc4f096b..a02d853be1a 100644
--- a/intern/cycles/kernel/svm/svm_hsv.h
+++ b/intern/cycles/kernel/svm/svm_hsv.h
@@ -46,6 +46,11 @@ ccl_device void svm_node_hsv(KernelGlobals *kg, ShaderData *sd, float *stack, ui
color.y = fac*color.y + (1.0f - fac)*in_color.y;
color.z = fac*color.z + (1.0f - fac)*in_color.z;
+ /* Clamp color to prevent negative values cauzed by oversaturation. */
+ color.x = max(color.x, 0.0f);
+ color.y = max(color.y, 0.0f);
+ color.z = max(color.z, 0.0f);
+
if (stack_valid(out_color_offset))
stack_store_float3(stack, out_color_offset, color);
}