diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-02-13 18:58:54 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-02-13 19:06:30 +0300 |
commit | ec559912fbcb51b713e1f33d4931af5fb52fd85b (patch) | |
tree | 7e8d2671055f1a606671c3e5f2de821cda9b4e0e /source/blender/nodes/shader | |
parent | 79f5b825a9779309a737bcbdfe3d68d760a80e62 (diff) |
Fix T61470: inconsistent HSV node results with saturation > 1.0.
Values outside the 0..1 range produce negative colors, so now clamp to that
range everywhere. Also fixes improper handling of hue > 2.0 in some places.
Diffstat (limited to 'source/blender/nodes/shader')
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_hueSatVal.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c b/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c index 62465000719..b52681190b4 100644 --- a/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c +++ b/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c @@ -46,9 +46,8 @@ static void do_hue_sat_fac(bNode *UNUSED(node), float *out, float hue, float sat float col[3], hsv[3], mfac = 1.0f - fac; rgb_to_hsv(in[0], in[1], in[2], hsv, hsv + 1, hsv + 2); - hsv[0] += (hue - 0.5f); - if (hsv[0] > 1.0f) hsv[0] -= 1.0f; else if (hsv[0] < 0.0f) hsv[0] += 1.0f; - hsv[1] *= sat; + hsv[0] = fmodf(hsv[0] + hue + 0.5f, 1.0f); + hsv[1] *= clamp_f(sat, 0.0f, 1.0f); hsv[2] *= val; hsv_to_rgb(hsv[0], hsv[1], hsv[2], col, col + 1, col + 2); |