Math behind Light Adaption

Started by
2 comments, last by wolf 17 years, 6 months ago
I currently have this for light adaption. AdaptedLum + (CurrentLum - AdaptedLum) * ( 1 - pow( 0.98f, FPS * ElapsedTime) ); Now I would like to use something based on half life ... actually a colleague suggested to use half-life like this: AdaptedLum + (CurrentLum - AdaptedLum) * ( 1 - exp(ElapsedTime / half-life) ); How do I calculate the half-life term here? What I found is: T1/2 = ln(2) / lambda lambda is the decay constant, a positive constant used to describe the rate of exponential decay. What would lamdba be in this case? What we want to achieve here is framerate independance. The old equation changed with framerate. Any help is appreciated, - Wolf ... I should probably add, this is not C++ code ... this is HLSL code ... [Edited by - wolf on October 20, 2006 9:54:15 PM]
Advertisement
what I actually need is a framerate indpendent blending between the previous frame luminance and the current frame luminance ...
Exponential decay is always in the form Ae-λt. Lambda is related to the half-life using the equation you presented, so you have to decide on a half-life first and then calculate lambda. Let t be ElapsedTime, and you get:

AdaptedLum + (CurrentLum - AdaptedLum) * (1 - exp(-lambda * ElapsedTime));

One common mistake is to confuse τ, which is the time constant, with the half-life. The two aren't the same! Tau is simply the inverse of lambda, while the half-life is really just a more intuitive way for us to deal with decay.
Thanks a lot! This was great!

This topic is closed to new replies.

Advertisement