It seems that sRGB has a better way for preserving low-brightness colors, compared to "plain" gamma correction.
As the gamma (and inverse gamma) LUT calculation is not in any hot path, we should try if the sRGB pedant holds its promise to provide smoother transitions at low brightness.
https://en.wikipedia.org/wiki/SRGB#Transfer_function_(%22gamma%22)
The math looks easy, by just replacing the "pow()" expression with the sRGB transfer function.
It's important to also adjust the inverse correction to use the inverse sRGB transfer function.
Edit: the sRGB transfer function uses a gamma exponent of 2.4, the resulting curve approximates a gamma=2.2 curve. I thinks it's possible to derive the correct scaling and offset coefficients for other gamma values - the wikipedia article shows the basic equations needed.
It seems that sRGB has a better way for preserving low-brightness colors, compared to "plain" gamma correction.
As the gamma (and inverse gamma) LUT calculation is not in any hot path, we should try if the sRGB pedant holds its promise to provide smoother transitions at low brightness.
https://en.wikipedia.org/wiki/SRGB#Transfer_function_(%22gamma%22)
The math looks easy, by just replacing the "pow()" expression with the sRGB transfer function.
It's important to also adjust the inverse correction to use the inverse sRGB transfer function.
Edit: the sRGB transfer function uses a gamma exponent of 2.4, the resulting curve approximates a gamma=2.2 curve. I thinks it's possible to derive the correct scaling and offset coefficients for other gamma values - the wikipedia article shows the basic equations needed.