Atmospheric Scattering Effects
2010, Dr. Lawlor, CS
481/681, CS, UAF
Light interacts with large masses of air in one of two ways:
- The distant geometry's light is scattered out of the ray by the air, causing distant geometry to get dimmer.
- Sunlight is scattered into the ray by the air, causing distant geometry to get bluer (more sky colored).
Eventually, you can't see the difference between distant geometry
and the sky, because all the geometry's light has been scattered out,
and replaced with scattered-in sky light.
Numerically, the fraction of geometry light remaining after travelling
a distance t, which we'll call G(t), starts off with G(0)=1.0, and drops off at some
rate until G(infinity)=0.0. We have to assume something about the
rate at which the atmosphere scatters light. For example, if we
assume the geometry light gets darker by 10% for every unit distance,
or:
d G / d t = -0.1
Then we can integrate to find G(t)=1.0-0.1*t. The only problem with this is that G(10)=0.0, and then G goes negative!
A better choice is to assume that the sky scatters out 10% of the *existing* light per unit distance, or:
d G / d t = -0.1*G(t)
The solution to this is a function that is its own derivative, G(t) = e-kt. Then
d G / d t = -ke-kt
so we can read off that the scattering rate k=0.1.
In a raytracer, if a ray travels a distance t, then we need to darken the geometry at the end of the ray by G(t) = e-kt.
The fraction of atmosphere light scattered into the ray is
1.0-G(t). See the example code for how this is implemented!
Typical scattering rates for the real atmosphere are a few percent per
mile for clear air; in foggy conditions this reach to several percent
per foot!