w3c / csswg-drafts

CSS Working Group Editor Drafts
https://drafts.csswg.org/
Other
4.48k stars 659 forks source link

[css-colors-4] Clarify whether RGB is additive or not #9977

Closed cdoublev closed 8 months ago

cdoublev commented 8 months ago

In 2. Color Terminology:

[...] Most RGB spaces are not additive

And later:

RGB color spaces are additive [...]

This seems contradictory. I guess most RGB color spaces are not linear, but they are all additive.

The subtractive process create colors by blocking the light whereas the additive process create colors by adding lights.

svgeesus commented 8 months ago

Right, that is sloppy.

But to restore the parts you clipped out

An additive color space means that the coordinate system is linear in light intensity. In an additive color space, calculations can be done to accurately predict color mixing.

These are correct.

Most RGB spaces are not additive, because the components are gamma encoded. Undoing this gamma encoding produces linear-light values.

This is also correct.

RGB color spaces are additive,

Should be

Thus, linearized RGB color spaces are additive,

By the way, you say

I guess most RGB color spaces are not linear, but they are all additive.

Not by the formal definition (accurate prediction of the color of mixed light); only by the fairy tale definition of "light is additive, pigment is subtractive, cyan = 1 - red" and so on which is wrong in so many ways. It is sadly common (including in older CSS and SVG specifications, and in the definitions of HSL and HWB) to do arithmetic on gamma-encoded RGB values; and the results from such calculations are incorrect in that they fail to predict the resulting color.

cdoublev commented 8 months ago

Do you have a reference with the formal definition to recommend to me?

svgeesus commented 8 months ago

Not at the moment, I am traveling, but I can find something once I am back home and have access to Color Science books again.

svgeesus commented 8 months ago

However, to give you something to go on meanwhile, additivity is one consequence of Grassman's Laws which form the basis of modern colorimetry (subject to certain conditions, which that link also states). And they are generally true but can break down under certain conditions, termed additivity failure. As an example, if human subject color matching tests are performed to match a given hue at different levels of chroma, the results do not exactly fall on a straight line on a chromaticity diagram but on a slightly curved line.

cdoublev commented 8 months ago

Thanks for the links.

I have only basic knowledge of colorimetry based on various literatures and experiences in color correction and graphic/web design. I know that one have either to use linear RGB or apply manual compensations in order to create realistic color shadows/highlights, blend colors, etc. I guess this is why SVG filter primitives operate in linear RGB by default.

I have just never come across the formal definition. Unfortunately, the "fairy tale" definition seems to be much more widespread than the formal definition and the explicit statement "(most) RGB color spaces are not additive", which yields results with the opposite statement when searching it on the web.

So the presence of the two opposing statements in the spec (before your fix) was all the more unfortunate. I am not sure the spec should ellaborate more on this though.