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/gpu | |
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/gpu')
-rw-r--r-- | source/blender/gpu/shaders/gpu_shader_material.glsl | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl index ab044fff100..970bbe641d4 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -881,12 +881,9 @@ void hue_sat(float hue, float sat, float value, float fac, vec4 col, out vec4 ou rgb_to_hsv(col, hsv); - hsv[0] += (hue - 0.5); - if (hsv[0] > 1.0) hsv[0] -= 1.0; else if (hsv[0] < 0.0) hsv[0] += 1.0; - hsv[1] *= sat; - if (hsv[1] > 1.0) hsv[1] = 1.0; else if (hsv[1] < 0.0) hsv[1] = 0.0; - hsv[2] *= value; - if (hsv[2] > 1.0) hsv[2] = 1.0; else if (hsv[2] < 0.0) hsv[2] = 0.0; + hsv[0] = fract(hsv[0] + hue + 0.5); + hsv[1] = hsv[1] * clamp(sat, 0.0, 1.0); + hsv[2] = hsv[2] * value; hsv_to_rgb(hsv, outcol); |