From f9b5b0efd22291cdbef6bc6189aa130fd253f2bb Mon Sep 17 00:00:00 2001 From: Omar Emara Date: Tue, 9 May 2023 14:22:35 +0300 Subject: [PATCH] Fix #107583: HSV node gives differ from CPU compositor The HSV node in the realtime compositor produces different values from the CPU compositor in its identity settings. This happens because the realtime compositor clamped the saturation value after HSV correction, while the CPU compositor did not, so this patch unifies that behavior. Additionally, negative values are now clamped in both the HSV node and Hue correction node to also match the CPU compositor. --- .../shaders/library/gpu_shader_compositor_hue_correct.glsl | 1 + .../library/gpu_shader_compositor_hue_saturation_value.glsl | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/source/blender/compositor/realtime_compositor/shaders/library/gpu_shader_compositor_hue_correct.glsl b/source/blender/compositor/realtime_compositor/shaders/library/gpu_shader_compositor_hue_correct.glsl index 99eb125cdf2..1535dc615f0 100644 --- a/source/blender/compositor/realtime_compositor/shaders/library/gpu_shader_compositor_hue_correct.glsl +++ b/source/blender/compositor/realtime_compositor/shaders/library/gpu_shader_compositor_hue_correct.glsl @@ -34,6 +34,7 @@ void node_composite_hue_correct(float factor, hsv.y = clamp(hsv.y, 0.0, 1.0); hsv_to_rgb(hsv, result); + result.rgb = max(result.rgb, vec3(0.0)); result = mix(color, result, factor); } diff --git a/source/blender/compositor/realtime_compositor/shaders/library/gpu_shader_compositor_hue_saturation_value.glsl b/source/blender/compositor/realtime_compositor/shaders/library/gpu_shader_compositor_hue_saturation_value.glsl index dd5eb33d318..0e1cb28e144 100644 --- a/source/blender/compositor/realtime_compositor/shaders/library/gpu_shader_compositor_hue_saturation_value.glsl +++ b/source/blender/compositor/realtime_compositor/shaders/library/gpu_shader_compositor_hue_saturation_value.glsl @@ -7,10 +7,11 @@ void node_composite_hue_saturation_value( rgb_to_hsv(color, hsv); hsv.x = fract(hsv.x + hue + 0.5); - hsv.y = clamp(hsv.y * saturation, 0.0, 1.0); + hsv.y = hsv.y * saturation; hsv.z = hsv.z * value; hsv_to_rgb(hsv, result); + result.rgb = max(result.rgb, vec3(0.0)); result = mix(color, result, factor); }