From 3417f3512be9b5cce8b9aeb821b81f4d1e80935d Mon Sep 17 00:00:00 2001 From: Carlos Lopez Date: Sun, 11 Aug 2024 19:07:38 -0400 Subject: [PATCH] fix(huecorrection): fix chroma restore --- src/shaders/RenoDRT.hlsl | 8 ++++---- src/shaders/colorgrade.hlsl | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/shaders/RenoDRT.hlsl b/src/shaders/RenoDRT.hlsl index aea9542a..784f121b 100644 --- a/src/shaders/RenoDRT.hlsl +++ b/src/shaders/RenoDRT.hlsl @@ -100,10 +100,10 @@ float3 BT709( if (hue_correction_strength == 1.f) { lch_new[2] = restore_lch[2]; // Full hue override } else { - lab_new = float3(lab_new[0], lerp(lab_new.yz, restore_lab.yz, hue_correction_strength)); - float3 lch_temp = lab_new = renodx::color::oklch::from::OkLab(lab_new); - lch_temp[1] = lch_new[1]; // custom chroma restore - lch_new = lch_temp; + float old_chroma = lch_new[1]; // Store old chroma + lab_new.yz = lerp(lab_new.yz, restore_lab.yz, hue_correction_strength); + lch_new = renodx::color::oklch::from::OkLab(lab_new); + lch_new[1] = old_chroma; // chroma restore } } diff --git a/src/shaders/colorgrade.hlsl b/src/shaders/colorgrade.hlsl index 649a5201..54be1356 100644 --- a/src/shaders/colorgrade.hlsl +++ b/src/shaders/colorgrade.hlsl @@ -71,10 +71,10 @@ float3 UserColorGrading( if (hue_correction_strength == 1.f) { lch_new[2] = restore_lch[2]; // Full hue override } else { - lab_new = float3(lab_new[0], lerp(lab_new.yz, restore_lab.yz, hue_correction_strength)); - float3 lch_temp = lab_new = renodx::color::oklch::from::OkLab(lab_new); - lch_temp[1] = lch_new[1]; // custom chroma restore - lch_new = lch_temp; + float old_chroma = lch_new[1]; // Store old chroma + lab_new.yz = lerp(lab_new.yz, restore_lab.yz, hue_correction_strength); + lch_new = renodx::color::oklch::from::OkLab(lab_new); + lch_new[1] = old_chroma; // chroma restore } }