[Bf-blender-cvs] [9886ae63311] blender2.7: Fix T61470: incorrect saturation clamping in recent bugfix.

Brecht Van Lommel noreply at git.blender.org
Thu Feb 14 19:44:34 CET 2019


Commit: 9886ae63311da83d962a546bb2c252316ba63538
Author: Brecht Van Lommel
Date:   Thu Feb 14 19:03:59 2019 +0100
Branches: blender2.7
https://developer.blender.org/rB9886ae63311da83d962a546bb2c252316ba63538

Fix T61470: incorrect saturation clamping in recent bugfix.

We should clamp the result after multiplication.

===================================================================

M	intern/cycles/kernel/shaders/node_hsv.osl
M	intern/cycles/kernel/svm/svm_hsv.h
M	source/blender/gpu/shaders/gpu_shader_material.glsl
M	source/blender/nodes/shader/nodes/node_shader_hueSatVal.c

===================================================================

diff --git a/intern/cycles/kernel/shaders/node_hsv.osl b/intern/cycles/kernel/shaders/node_hsv.osl
index 9d7b7cde23a..d72a87a951f 100644
--- a/intern/cycles/kernel/shaders/node_hsv.osl
+++ b/intern/cycles/kernel/shaders/node_hsv.osl
@@ -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);
diff --git a/intern/cycles/kernel/svm/svm_hsv.h b/intern/cycles/kernel/svm/svm_hsv.h
index e69a4ee9154..6f3efa639e2 100644
--- a/intern/cycles/kernel/svm/svm_hsv.h
+++ b/intern/cycles/kernel/svm/svm_hsv.h
@@ -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);
diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl
index 970bbe641d4..c269185eb0f 100644
--- a/source/blender/gpu/shaders/gpu_shader_material.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_material.glsl
@@ -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);
diff --git a/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c b/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c
index b52681190b4..33e80ce2ab0 100644
--- a/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c
+++ b/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c
@@ -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);



More information about the Bf-blender-cvs mailing list