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:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2019-02-13 18:58:54 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2019-02-13 19:06:30 +0300
commitec559912fbcb51b713e1f33d4931af5fb52fd85b (patch)
tree7e8d2671055f1a606671c3e5f2de821cda9b4e0e /source/blender/gpu/shaders
parent79f5b825a9779309a737bcbdfe3d68d760a80e62 (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/shaders')
-rw-r--r--source/blender/gpu/shaders/gpu_shader_material.glsl9
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);