-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exposing ColorSpaceWhitePoint
is too heavyweight, and doesn't actually fix equality
#30
Comments
Alternate proposal:
This way authors can check if it's the predefined whitepoint by using reference equality:
This is a forward-compatibility hazard, since we'll be prepopulating it. To make it safe to add more predefined whitepoints in the future we'd have to allow new regs to override existing ones. |
That sounds reasonable (and is what CSS Color 4 was doing, at first) but led to a world of pain and multiple rewrites of conversion matrices over the last couple of years due to weird non-chromatic values on neutrals from color conversions. These were actually visible (yellowing) as well as being unexpected and annoying. Which is why CSS Color 4: white points now says:
and then gives the exact values with 6-digit precision, with zeroes for any subsequent digits. So it was important for round-trippability that D65 was I'm aware that we can't really compare floats for equality, but the tiny tolerance is going to be Comparing objects does sound like a better way forward. |
We should probably be doing the test on set actually, not get, and if it's within a tolerance of the predefined, just correct it to exactly the predefined. |
The downside with this approach is that if we have multiple color spaces sharing the same (non D50, non D65) white point, we don't get the convenient "if close enough, cast to the same object" behavior. We should probably also not hang these directly on |
Yeah, you do lose the easy testing there, but... how important is that? How common are whitepoints other than D50 and D65? And if people have easy testing of those two, is it worth adding a whole registration mechanism over just having people write a convenience method that compares two whitepoints? |
That's a question for @svgeesus . IIRC there was only one HDR color space that used a different white point.
It's not so much the inconvenience, but the inconsistency that rubs me the wrong way. There is a certain "magic" built-in behavior that is not exposed and cannot be extended. I worry it's a bit of a footgun. I also cannot think of any other API in the Web Platform that does something similar. Another direction we could go is to only have predefined whitepoints in L1 (either as objects or as strings), and see what happens and design L2 based on input from use cases. |
The downside of having predefined static attributes directly on a class is that there's no easy way to enumerate these whitepoints. You'd need to enumerate all static properties and filter out those that don't match. And if there is no class for white points this can only be done with duck typing ( What about the following design:
Then Color API would use Note that how this is done is important, not just for developers wishing to compare two ColorSpace objects for whitepoints (rather uncommon), but primarily internally: Color API needs to know when two color spaces have the same or different white point, to see if it needs to do chromatic adaptation when converting between these spaces. |
Sounds good to me. |
The Digital Cinema Initiative colorspace, DCI-P3, uses a weird greenish white (0.314, 0.351) for reasons to do with the xenon bulb used in digital projectors. detailsThe DCI white is an ‘ugly green-white’ that was only there because projector manufacturers were concerned about achieving maximum brightness at 14fL for colors on the daylight axis. Getting to D60 or D65 was considered 5-12% less efficient.D65 comes across as both a bit too ‘cool’ in appearance for live action content in a dim theatrical grading environment, and at the same time with Xenon projection lamps can have a magenta bias when looking at a full grey field. This is a reaction between the spectrum of Xenon and the eye color sensitivities. Testing at the Academy of Motion Pictures Arts and Sciences showed that D60 is a more appropriate ‘creative white’ (also called adopted white) for live action content. This is why it is chosen as the white point of the ACES system. The Academy Color Encoding Specification (ACES) colorspaces use (0.32168, 0.33767) which is similar to D60. So, not very, but a fully-fledged system does need to account for them. An MVP system can do just fine with D65 and D50. |
Oh, and I am answering the more specific question "How common are color spaces that use whitepoints other than D50 and D65?" here. In general color science they are a lot more common, used for tasks like "I measured these printed colors with this illuminant, now adapt them to D50 please". That is well outside the scope of this API, but that is why we support arbitrary white points and multiple chromatic adaptation algorithms in color.js. |
Yes, this is crucial otherwise all the affected conversions are just plain wrong.
My point was that if someone registers myD65 which is similar but not identical to D65, the system will treat that as different, compute a chromatic adaptation matrix which is similar but not identical to unity, and apply it to get the right result. In other words it accepts it gracefully and gives the correct result. |
Right now, the API defines a
ColorSpaceWhitePoint
class, with static predefined valuesColorSpaceWhitePoint.D50
andColorSpaceWhitePoint.D65
that authors are supposed to reference in creatingColorSpace
objects.This means that in the case where the white point is something else, code would need to do things like
if (c.white.x === ACES.x && c.white.y === ACES.y)
to compare with it, not to mention that things likeif (c.white === ColorSpaceWhitePoint.D65)
do not account for creating ColorSpaceWhitePoint objects with the same x and y values as the predefined ones (which should really be identified as D50/D65).Also, exposing a whole other interface just for this seems pointlessly heavyweight.
I would propose a different design:
ColorSpace
to register a custom white point, which does not allow registration of duplicate valuesColorSpace
to look up white point chromaticity values by their nameColorSpaceOptions.white
would be a string, referencing a registered whitepointThis would allow handling white points as plain strings making equality checks easy.
Thoughts @svgeesus @tabatkins ?
The text was updated successfully, but these errors were encountered: