Re: [csswg-drafts] [css-color-4] Evaluate static gamut mapping algorithms for oklab/oklch spaces (#10579)

Adding some data I recently observed and I haven't seen brought up before. It appears that clipping produces a *much* worse color for higher lightnesses whereas it is much more acceptable for medium to low lightness even for fairly substantial clips.

Demo: https://codepen.io/leaverou/pen/KwdMVVG
Tweak the color on the left and see how different L values render, both raw in the browser (currently clipped) and gamut mapped to P3 and sRGB.
The very light colors suffer the most, even when the original color was only slightly out of gamut, which worries me about the approach of "gamut map to REC 2020 and then clip"  discussed here:

<img width="1799" height="530" alt="Image" src="https://github.com/user-attachments/assets/677af1f8-6434-4fa9-921e-3fea37841aaa" />

Whereas for the rest, you need to be much more significantly OOG to see a significant difference, so this approach would work fine:

<img width="1799" height="529" alt="Image" src="https://github.com/user-attachments/assets/8402c5ad-3c24-48f3-9593-c11f169fd260" />

I wonder if rather than having a fixed "gamut map to REC 2020 and then clip" algorithm we could have a fast lightness test and take different code paths, using clipping more for darker colors and more gamut mapping for very light colors.

-- 
GitHub Notification of comment by LeaVerou
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/10579#issuecomment-3200476676 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 19 August 2025 12:03:29 UTC