sRGB
The sRGB luminance curve is designed to be an approximation of a gamma 2.2 curve, but with a straightline portion near zero to avoid rounding errors in conversions.
Duh.
It's hard to find good online resources with the to- and from-sRGB conversions expressed in language compatible with nerdy compositing applications, so I thought I’d consolidate some findings here.
Spitzak has the sRGB to linear conversion right:
x < .04045 ? x/12.92 : pow((x+.055)/1.055, 2.4)
And here’s its inverse:
x < .0031308 ? x*12.92 : (1.055*pow(x,1/2.4)) -0.055
The question mark is an if/then. If the conditional before it is true, do what’s before the colon. If false, do what’s after.
Boom.
Reader Comments (3)
Thank you very much for this info, very helpful for what I need right now!
Thanks again, cheers,
- loocas
how can you include softclipping in this formula?
vfx-pedia posted a way of soft cliping values above 1 in a floating point image.
http://vfxpedia.com/index.php?title=SoftClip_Description
That's a perfectly good softclipping formula, and you could experiment with including it either before or after the linear-to-sRGB conversion. There's no reason to merge the two into one formula if you're working in float.