bugfix: [#29711] Cycles - HSV Node - Hue Change Bug
authorDalai Felinto <dfelinto@gmail.com>
Thu, 29 Dec 2011 05:40:48 +0000 (05:40 +0000)
committerDalai Felinto <dfelinto@gmail.com>
Thu, 29 Dec 2011 05:40:48 +0000 (05:40 +0000)
* Adding hue instead of removing it.

fmod doesn't work as % when it comes to negative numbers:
fmod( 1.3, 1) ==  1.3 % 1 == 0.3
fmod(-0.3, 1) != -0.3 % 1

intern/cycles/kernel/osl/nodes/node_hsv.osl
intern/cycles/kernel/svm/svm_hsv.h

index da776c8909e9efa4c650dc063512a3703b958136..8fd7a1612e88ad153fb2c8fc110e80aa5239ac51 100644 (file)
@@ -30,7 +30,8 @@ shader node_hsv(
        float t = clamp(Fac, 0.0, 1.0);
        color Color = rgb_to_hsv(ColorIn);
 
-       Color[0] += Hue - 0.5;
+       // remember: fmod doesn't work for negative numbers
+       Color[0] += Hue + 0.5;
        Color[0] = fmod(Color[0], 1.0);
        Color[1] *= Saturation;
        Color[2] *= Value;
index fc927f297f55b1b89d296824a4517ecfccf13504..ed17d3fc985ee7aa4cb6c7e1cb3d73c0b2c1ebae 100644 (file)
@@ -110,7 +110,8 @@ __device void svm_node_hsv(KernelGlobals *kg, ShaderData *sd, float *stack, uint
 
        color = rgb_to_hsv(color);
 
-       color.x += hue - 0.5f;
+       // remember: fmod doesn't work for negative numbers
+       color.x += hue + 0.5f;
        color.x = fmod(color.x, 1.0f);
        color.y *= sat;
        color.z *= val;