11-14-07 - 2

A little more on the rough Gamma thing. Another cute thing to do would be to go ahead and combine our Gamma step with an Exposure step. Now instead of taking linear light in [0,1] we're taking brightness in [0,inf] and we still want to output in [0,255].

We want a function like 255*(1 - exp( - C * x )). For x = 0 we output zero, and we get 255 as x -> inf.

We can make this match the gamma curve for low x. Again just assume gamma = 2 and match against sqrt. When you do the integral to optimize C, you get an error function which you can't solve analytically so you have to do it numerically. I just ran rough numbers and got C = 2.69 which is awfully close to "e" (2.718) so I wonder if I did it more precisely if I would actually get "e".

Anyway that's not what we really want, cuz the exposure for large values is very different. We really only want to force them to match for the small values of x. If you optimize for the low value of x you get C = 3.0 almost exactly. (again we're integrating in steps of sqrt(x) not in steps of x).

So our combined gamma + exposure function is :

255*(1 - exp( - 3 * x ))

I have no idea if this is actually cool, I haven't tried it yet or anything.

Won says a more common tone mapping form is x/(x+C). The optimal C for matching sqrt in the low range is around C = 0.25 This form is actually a better match for sqrt in that range, but has the disadvantage of being pretty far off 1.0 when x is 1.0 (it's only 0.8, unlike the exp form which is 0.95).

Both of these forms are actually pretty shitty for very low x which is pretty bad. They do a bit better if you use e^(-4*x) or x/(x+0.2)

No comments:

old rants