Description
The sample code for converting from XYZ to OKLab involves taking the cube root of the result of multiplying the XYZ color by the XYZtoLMS
matrix. This is undefined for negative numbers, and returns NaN
, despite the fact that the XYZ color space is notionally unbounded and thus could very easily produce negative numbers.
This comes up even with fairly reasonable in-bounds colors. For example, lab(0.01% 35 1)
is equivalent to xyz(0.008679770007260038 0.000011070564598794538 -0.0005206593067627204)
, which converts to LMS as [0.006751691618866409, 0.000022646971037596888, -0.00003832537822546193]
.
Should the LMS logic clamp channels so that they're 0 at minimum? Should it take the cube root of the absolute value and then match the sign afterwards?