Skip to content

Commit d8c8838

Browse files
committed
Cleanups
1 parent 32ac1b3 commit d8c8838

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

shaders/cChromaticity.fx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,17 @@ float4 PS_Chromaticity(CShade_VS2PS_Quad Input) : SV_TARGET0
6767
Chromaticity.rg = CColor_GetHSVfromRGB(Color).rg;
6868
break;
6969
case 13: // CoCg (XY)
70-
Chromaticity.rg = CColor_GetYCOCGfromRGB(Gamma, true).yz + 0.5;
70+
Chromaticity.rg = CColor_GetYCOCGfromRGB(Gamma, true).yz;
7171
break;
7272
case 14: // OKLab (AB)
73-
Chromaticity.rg = CColor_GetOKLABfromRGB(Color).yz + 0.5;
73+
Chromaticity.rg = CColor_GetOKLABfromRGB(Color).yz;
74+
Chromaticity.rg = (Chromaticity.rg + 0.4) / 0.8;
7475
break;
7576
case 15: // OKLch (CH)
76-
Chromaticity.rg = CColor_GetOKLCHfromRGB(Color, true).yz;
77+
const float Pi2 = CMath_GetPi() * 2.0;
78+
Chromaticity.rg = CColor_GetOKLCHfromRGB(Color).yz;
79+
Chromaticity.r /= length(float2(0.4, 0.4));
80+
Chromaticity.g /= Pi2;
7781
break;
7882
default: // No Chromaticity
7983
Chromaticity.rgb = 0.0;

shaders/shared/cColor.fxh

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -393,14 +393,12 @@
393393
return LMS;
394394
}
395395

396-
float3 CColor_GetOKLCHfromOKLAB(float3 OKLab, bool Normalize)
396+
float3 CColor_GetOKLCHfromOKLAB(float3 OKLab)
397397
{
398-
const float Pi2 = CMath_GetPi() * 2.0;
399398
float3 OKLch = 0.0;
400399
OKLch.x = OKLab.x;
401400
OKLch.y = length(OKLab.yz);
402401
OKLch.z = atan2(OKLab.z, OKLab.y);
403-
OKLch.z = (Normalize) ? OKLch.z / Pi2 : OKLch.z;
404402
return OKLch;
405403
}
406404

@@ -413,9 +411,9 @@
413411
return OKLab;
414412
}
415413

416-
float3 CColor_GetOKLCHfromRGB(float3 Color, bool Normalize)
414+
float3 CColor_GetOKLCHfromRGB(float3 Color)
417415
{
418-
return CColor_GetOKLCHfromOKLAB(CColor_GetOKLABfromRGB(Color), Normalize);
416+
return CColor_GetOKLCHfromOKLAB(CColor_GetOKLABfromRGB(Color));
419417
}
420418

421419
float3 CColor_GetRGBfromOKLCH(float3 OKLch)
@@ -569,7 +567,7 @@
569567
Color.y += Tint;
570568

571569
// Convert OKLab to OKLch
572-
Color = CColor_GetOKLCHfromOKLAB(Color, false);
570+
Color = CColor_GetOKLCHfromOKLAB(Color);
573571

574572
// Apply lightness
575573
Color.x *= Lightness;

0 commit comments

Comments
 (0)