Re: [csswg-drafts] [css-color-4] (ok)lch implementations break the entire purpose for authors (#9449)

I agree that the `oklab` and `oklch` spaces work best when paired with gamut mapping, and I think that the CSS gamut mapping algorithm produces good results for these spaces.

However, I do believe that the CSS gamut mapping algorithm can be inappropriate to apply to other things like `display-p3` colors, because doing so can produce results that are undesirable (e.g, [this example](https://github.com/w3c/csswg-drafts/issues/7610#issuecomment-1226026465) with reds). The CSS gamut mapping algorithm is really built for `oklab` and `oklch` (I might be tempted to call it something like "`okl` gamut mapping")

I think that the best way forward would be to "bake" CSS gamut mapping in to the definitions of `oklab` and `oklch`.

The difficulty is to define exactly what "baking" to do. Mapping to the display's gamut might be okay, but on sRGB-ish devices, it might do surprising things. When drawing to a canvas, the mapping cannot depend on the device's color space (ignoring fingerprinting, we just wouldn't want the non-determinism), and I don't think that mapping to the canvas' space would be that good (sRGB is the default and is very narrow).

One scheme would be something where we bake a well-known gamut into `oklab` and `oklch`, so we end up in effect having `oklab-srgb` or `oklab-p3` or `oklab-rec2020` (and the vanilla `oklab` defaults to one of those). I'm not a huge fan of this. The resulting geometries in `oklab` are very nonconvex and can have some sharp edges.

A better scheme could be to define a standard polyhedron to always do gamut mapping to, then I think that would be a really good way forward. This polyhedron should be big -- maybe as big as the spectral colors. And it could be made to be convex. (And maybe we could define it as being smooth).

I've been using [this tool](https://ccameron-chromium.github.io/webgl-examples/gamut.html) to visualize some of these options.

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


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

Received on Wednesday, 29 November 2023 21:50:59 UTC