Fix T61470: incorrect saturation clamping in recent bugfix.

We should clamp the result after multiplication.
This commit is contained in:
Brecht Van Lommel 2019-02-14 19:03:59 +01:00
parent fb6f1aa12f
commit 9886ae6331
Notes: blender-bot 2023-02-14 05:22:18 +01:00
Referenced by issue #61470, Color Issue
4 changed files with 4 additions and 4 deletions

View File

@ -29,7 +29,7 @@ shader node_hsv(
// remember: fmod doesn't work for negative numbers
Color[0] = fmod(Color[0] + Hue + 0.5, 1.0);
Color[1] *= clamp(Saturation, 0.0, 1.0);
Color[1] = clamp(Color[1] * Saturation, 0.0, 1.0);
Color[2] *= Value;
Color = hsv_to_rgb(Color);

View File

@ -38,7 +38,7 @@ ccl_device void svm_node_hsv(KernelGlobals *kg, ShaderData *sd, float *stack, ui
/* remember: fmod doesn't work for negative numbers here */
color.x = fmodf(color.x + hue + 0.5f, 1.0f);
color.y *= saturate(sat);
color.y = saturate(color.y * sat);
color.z *= val;
color = hsv_to_rgb(color);

View File

@ -882,7 +882,7 @@ void hue_sat(float hue, float sat, float value, float fac, vec4 col, out vec4 ou
rgb_to_hsv(col, hsv);
hsv[0] = fract(hsv[0] + hue + 0.5);
hsv[1] = hsv[1] * clamp(sat, 0.0, 1.0);
hsv[1] = clamp(hsv[1] * sat, 0.0, 1.0);
hsv[2] = hsv[2] * value;
hsv_to_rgb(hsv, outcol);

View File

@ -47,7 +47,7 @@ static void do_hue_sat_fac(bNode *UNUSED(node), float *out, float hue, float sat
rgb_to_hsv(in[0], in[1], in[2], hsv, hsv + 1, hsv + 2);
hsv[0] = fmodf(hsv[0] + hue + 0.5f, 1.0f);
hsv[1] *= clamp_f(sat, 0.0f, 1.0f);
hsv[1] = clamp_f(hsv[1] * sat, 0.0f, 1.0f);
hsv[2] *= val;
hsv_to_rgb(hsv[0], hsv[1], hsv[2], col, col + 1, col + 2);