From f9688d88ff528e94e0ac059c6fc41a163fb0f6be Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 31 Oct 2014 14:42:48 +0100 Subject: 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. --- intern/cycles/kernel/svm/svm_hsv.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'intern/cycles/kernel/svm') 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); } -- cgit v1.2.3