
Don’t Convert SRGB U8 to Linear U8 - ingve
https://blog.demofox.org/2018/03/10/dont-convert-srgb-u8-to-linear-u8/
======
kazinator
If you want to interpolate between colors, anything-RGB is wrong, even for the
best value of "anything". You want the LAB space, or something along those
lines.

If we interpolate between one RGB color to another color of equal intensity,
the intensity along the interpolation will not be constant.

~~~
mark-r
The gradient from pure red to pure green in linear RGB space isn't bad at all.
The problem comes when you interpolate between endpoints of different
intensities.

LAB isn't perfect either. Depending on your endpoints it can transition
through colors that are hardly related.

------
haneefmubarak
The author mentions that one should always convert to f32 for storage or
computation on linear values, but why not just use u16 or i16? You'd get both
the benefits of having an integer format and a smaller data type at that,
while still having the expanded space to prevent precision loss (depending on
what you want to do, you may have to be a touch careful, of course).

~~~
colanderman
Component values outside the (normalized) range [0,1] are necessary to
represent certain colors as sRGB (and most other color spaces). So if you're
color-space aware, at least i16 is warranted. f32 just means you have to worry
less about overflow, quantization effects, etc., that crop up with various
image manipulations. Plus, on GPUs, 32-bit floating point math is generally at
least as fast as integer math. So it comes only at a loss of space.

~~~
cwzwarich
On GPUs, fp16 is quite a bit more power-efficient (and bandwidth-efficient)
than fp32.

~~~
wtallis
Aren't there problems with FP16 support being far from universal, and many
GPUs having far less FP16 throughput than FP32? In some situations FP16 is
definitely a better choice, but I don't think it can be given as a blanket
recommendation.

~~~
cwzwarich
I work exclusively on embedded GPUs these days, so I was surprised to read
this. It's easy to repurpose FP32 hardware to at least support FP16 without
reduced performance. However, seems that Nvidia has intentionally reduced FP16
performance on some consumer products for market segmentation reasons.

------
John_KZ
Excuse me for my ignorance on the subject, but I thought gamma died with CRTs
and all RGB values on images are intensity representations on a linear scale.
Am I wrong? Is sRGB used for publishing or something?

~~~
tropo
Physically, gamma died with the CRT, but every LCD recreates it for
compatibility.

~~~
kevin_thibedeau
LCDs still have their own inherent "gamma" curve which is actually a sigmoid
shape. They just emulate CRT gamma for backwards compatibility and hide their
own low level details in the process.

------
banachtarski
Or just use the standard BCn or DXT formats. The compression in these as
texture formats is way smarter (for example, additional bits are used to
encode green which our eyes are more sensitive to). These are "lossy" formats
but when you go from PNG or something to a u8 format, you get artifacts for
sure.

~~~
EtDybNuvCu
Please don't use those DXTn formats; they're still legally toxic due to
patents.

~~~
floatboth
Not since last October.
[https://www.phoronix.com/scan.php?page=news_item&px=S3TC-
For...](https://www.phoronix.com/scan.php?page=news_item&px=S3TC-For-Mesa-
Finally)

