News for hackers. Stuff that matters.
Re:Better SRGB to Greyscale Conversion by uninformedprior on Sunday October 19, 2025 @04:47PM (#45637819)
I ran into this subjectiveness in graphics recently. Thought I was doing the "correct" thing blending in linear space but turns out blending in SRGB looks a lot better for certain applications and that's what most popular applications do.
Re:Better SRGB to Greyscale Conversion by Remnant44 on Sunday October 19, 2025 @07:04PM (#45638826)
I've run into this as well. Problem is that linear RGB is most definitely not a perceptually uniform space, so blending in it frequently does something different than you want. Use linear for physically based light and mixing, but if you are modeling an operation that is based on human perception it is going to be completely wrong.

The dark irony then, is that sRGB with its gamma curve applied, models luminance better (closer to human perception) for blending than linear does. If you can afford to do the blend in a perceptually uniform space like oklab, even better of course.

Re:Better SRGB to Greyscale Conversion by ChrisMarshallNY on Sunday October 19, 2025 @04:57PM (#45637909)
The thing that is difficult to "math," is that we perceive color in a certain way (if you ever look at the CIELAB[0] space, that's based on human eye perception). So there's a lot of "it just don't look right." involved.

I have found that getting weighted LUTs that have been extracted from some process (math, context measurements, user testing, etc.), and simply applying them in the conversion is how you execute the conversion, but generating the LUTs is the tricky part. It's not always best handled by a formula. I guess you could really go crazy, and generate the LUT on the fly, as a per-pixel conversion (we actually did something like this, for RAW conversion).

[0] https://en.wikipedia.org/wiki/CIELAB_color_space

Re:Better SRGB to Greyscale Conversion by zokier on Sunday October 19, 2025 @04:52PM (#45637855)
for blending oklab almost always works better than srgb (linear or gamma).
Re:Better SRGB to Greyscale Conversion by uninformedprior on Sunday October 19, 2025 @05:18PM (#45638082)
It's possible I wasn't specific enough when I said "graphics". Typically I blend in CIELAB when interpolating between colors for visualizations (eg data science).

But I'm unaware of rendering engines that do alpha blending in something other than linear or SRGB. Photoshop, for instance, blends in sRGB by default, while renderers that simulate light physically will blend in linear RGB (to the best of my knowledge).

It depends on the GPU and the implementation, but I personally would not want to spend the compute on per-pixel CIELAB conversions for blending.

Re:Better SRGB to Greyscale Conversion by zokier on Tuesday October 21, 2025 @07:45AM (#45654688)
> But I'm unaware of rendering engines that do alpha blending in something other than linear or SRGB.

Well, spectral rendering is a thing, kinda bypasses the problem of color blending for rendering in some cases.