Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Abstract
We present a new and accurate method to render the atmosphere in real time from any viewpoint from ground
level to outer space, while taking Rayleigh and Mie multiple scattering into account. Our method reproduces
many effects of the scattering of light, such as the daylight and twilight sky color and aerial perspective for all
view and light directions, or the Earth and mountain shadows (light shafts) inside the atmosphere. Our method is
based on a formulation of the light transport equation that is precomputable for all view points, view directions and
sun directions. We show how to store this data compactly and propose a GPU compliant algorithm to precompute
it in a few seconds. This precomputed data allows us to evaluate at runtime the light transport equation in constant
time, without any sampling, while taking into account the ground for shadows and light shafts.
Categories and Subject Descriptors (according to ACM CCS): I.3.7 [Computer Graphics]: Three-Dimensional
Graphics and Realism
1. Introduction method is the first real-time method accounting for all view-
points, all view and sun directions, and multiple scattering.
Atmospheric effects are very important to increase the real-
ism of outdoor scenes in many applications. The sky color The next sections are organized as follows. Section 2 in-
gives key indications about the hour of the day, and the troduces the physical model and the rendering equation and
aerial perspective gives an important cue to evaluate dis- reviews the related work. Section 3 presents our resolution
tances. Rendering these effects in real time, continuously method to get a precomputable formulation. Sections 4 and 5
from ground to space, is desirable in many games or applica- present our precomputation and rendering algorithms. Sec-
tions, such as flight simulators or Earth browsers like Google tion 6 gives implementation details and presents our results.
Earth. This is especially true for applications that target re-
alism, such as Celestia or Nasa WorldWind. However, these
2. Atmospheric models
applications currently use very basic models to render these
effects, which do not give realistic images. Rendering atmosphere illumination relies on two aspects: a
physical model of the local medium properties, and a simu-
In this paper we propose a method to render these effects
lation of the global illumination exchanges up to the viewer
in real time, from any viewpoint from ground to space. This
eyes. This includes exchanges with the ground, which can
method accounts for multiple scattering, which is important
be modeled as a Lambertian surface with a height field of
to correctly render twilight, or the shadow of the Earth in-
reflectance α(x, λ), normal n(x), etc.
side the atmosphere (see Figure 8). It is based on moderate
simplifying assumptions that allow us to get a better approx- Most computer graphics (CG) papers, starting with
imate solution of the rendering equation (compared to pre- [NSTN93], rely on a physical model of the medium com-
vious work), in which most terms can be precomputed. Our prising air molecules and aerosol particles, summarized in
mate solutions that are easier to compute (see [Slo02] for a functions of x, v, s such as L̄ or S̄[L̄] can be reduced to func-
survey). Most real-time methods ignore multiple scattering. tions of 4 parameters (2 for x, v and 2 for s). Note also that L
In this case Equation 8 reduces to L = L0 + R[L0 ] + S[L0 ]. (resp. L̄) can be expressed with a series in the linear opera-
However, even S[L0 ] is quite complex to solve. Some au- tors R and S (resp. R̄ and S̄), where the ith term corresponds
thors propose analytical solutions at the price of idealisa- to light reflected and/or scattered exactly i times:
tions: flat Earth with constant atmosphere density [HP02],
L = L0 + (R + S)[L0 ] + (R + S) (R + S)[L0 ] + . . .
or without Mie scattering [REK∗ 04]. The flat Earth hypoth-
esis limits them to observers on the ground. Otherwise, S[L0 ] = L 0 + L 1 + L2 + . . . = L0 + L ∗ (12)
is generally computed by numerical integration [NSTN93],
which can be done in real time using low sampling [O’N05]. Zero and single scattering We compute L0 and R[L0 ] ex-
A notable exception is [SFE07] who rely on precomputa- actly, during rendering. For this we use a shadowing algo-
tions of this integral. However, in order to reduce the num- rithm to compute the sun occlusion (see Equation 9), and a
ber of parameters, they only take into account the view and precomputed table for the transmittance T , which depends
sun zenith angles, and neglect the angle between the view on only 2 parameters (see Section 4). S[L0 ] is more compli-
and sun directions. Hence they cannot reproduce, e.g., the cated. It is an integral between x and xo but, due to the occlu-
Earth’s shadow inside the atmosphere. sion term in L0 , the integrand is null at all points y that are in
shadow (this is what gives light shafts). We suppose here that
Ignoring multiple scattering as above is acceptable for these points are between xs and xo (see Figure 1 – the gen-
daylight but not for twilight [HMS05]. This is because sun- eral case is discussed in Section 5). Then the integral can be
light traverses much less atmosphere during the day than reduced to the lit segment [x, xs ]. Moreover, occlusion can be
during sunset or sunrise. Hence, some authors propose meth- ignored since it is already accounted for via xs ,Ri.e., L0 can
ods to account for multiple scattering. [PSS99] fit the results be replaced with L̄0 . This shows that S[L0 ] = xxs T J [L̄0 ].
of a double scattering Monte-Carlo simulation with an ana- By rewriting this as xx̄o T J [L̄0 ] − xx̄so T J [L̄0 ], extending an
R R
lytical model, but their model is only valid for an observer on idea introduced in [O’N05] and reused in [SFE07], we fi-
the ground. [NDKY96] and [HMS05] use volume radiosity nally get a formulation using precomputable functions of 2
algorithms to compute multiple scattering, but their methods and 4 parameters, T and S̄[L̄0 ]:
are far from real-time (minutes to hours per image).
S[L0 ](x, v, s) = S̄[L̄0 ](x, v, s)−T (x, xs )S̄[L̄0 ](xs , v, s) (13)
In this paper we propose a new method to render the sky
and the aerial perspective in real time, from all viewpoints Multiple scattering As shown above L0 and L1 can be com-
from ground to space, while taking multiple scattering into puted exactly despite the occlusion. Unfortunately account-
account. It is inspired by [SFE07] and extends it with multi- ing for occlusion in the other terms L2 + . . . = R[L∗ ] + S[L∗ ]
ple scattering, with the previously ignored view-sun angle is much more difficult. Hopefully, in this case the occlusion
parameter, with a better parameterization for the precom- can be approximated. Indeed, multiple scattering effects are
puted tables, and with a new method for light shafts. small compared to single scattering during the day, while
the ground contribution is small when it is not directly lit
by the sun. So we approximate occlusion effects in S[L∗ ]
3. Our method by integrating the contribution of multiple scattering, com-
puted without occlusion, between x and xs . This yields both
For efficiency and realism, our goal is to precompute L as positive and negative bias (see Figure 1). Mathematically,
much as possible, with only minimal approximations. Our this approximation gives S[L∗ ] ' xxs T J [L̄∗ ]. We also ap-
R
solution is based on an exact computation for zero and sin- proximate occlusion effects in R[L∗ ] with the ambient oc-
gle scattering, and uses an approximation of occlusion ef- clusion of an horizontal hemisphere due to the ground’s tan-
fects to compute multiple scattering. In fact we take the de- gent plane, 1+n.n̄
2 . This gives R[L∗ ] ' R̂[L̄∗ ] with:
tailed ground shape into account for zero and single scatter-
ing, in order to get correct ground colors, shadows and light α(xo ) 1 + n(xo ).n̄(xo )
R̂[L̄∗ ] = T (x, xo ) Ē[L̄∗ ](xo , s) (14)
shafts. But we approximate it with a perfect sphere of con- Z
π 2
stant reflectance to compute multiple scattering, to allow for Ē[L̄∗ ](xo , s) = ω.n̄(xo )dω, or 0
L̄∗ (xo , ω , s)ω (15)
precomputation. 2π
By using the same rewriting rule as for Equation 13, and by
Notations Before presenting our method we need some no- noting S̄[L̄]|x = S̄[L̄](x, v, s), we finally get:
tations and auxiliary functions. We note L̄ = L̄0 +(R̄+ S̄)[L̄]
L ' L0 + R[L0 ] + R̂[L̄∗ ] + S̄[L̄]|x − T (x, xs )S̄[L̄]|xs (16)
the solution of Equation 8 for the case of a perfectly spher-
ical ground of constant reflectance ᾱ. L̄0 , R̄, S̄, x̄o , Ī and where the first three terms can be quickly computed with the
so on are defined as before, but for this spherical ground. help of precomputed 2D tables for T and Ē[L̄∗ ], and where
Note that thanks to the ground’s spherical symmetry x and v S̄[L̄] can be precomputed in a 4D table. We now show how
can be reduced to an altitude and a view zenith angle. Hence to precompute them, in tables of a reasonnable size.
4. Precomputations
We precompute T (x, x̄o (x, v)) for all x, v in a 2D table
T(x, v). Due to spherical symmetry, T depends only on
r = kxk and µ = v.x/r [O’N05]. As [O’N05], we then use the
identity T (x, y) = T(x, v)/T(y, v), with v = (y−x)/ky−xk.
We precompute Ē[L̄∗ ] and S̄[L̄] in two tables E and S with
an algorithm that computes each scattering order L̄i one after
the other. This algorithm uses three intermediate tables ∆E, Figure 4: Parameterization. ur , uµ , uµs as functions of r, µ, µs .
∆S and ∆J containing after each iteration i Ē[L̄i ], S̄[L̄i ] and
J [L̄i ]. ∆E and ∆S are added to the result tables E and S at √
the end of each iteration (R̄ is computed with the identity and d/ r2 + d 2 for xs , which gives ∆µ = 0.016 1 for
R̄[L](x, v, s) = T (x, x̄o ) ᾱπ Ē[L](x̄o , s) – see Algorithm 4.1). d = 100 km. This too small value gives visible artifacts (see
Figure 3). In order to solve this problem we rely on a bet-
Angular precision Since S is a 4D table its size increases ter parameterization. We replace µ with uµ , defined as the
very quickly with resolution. So we can only use a lim- ratio between the distance do = kx̄o − xk and the distance
ited angular resolution for v. This poses a precision prob- dh (resp. dH ) from x to the horizon (resp. to the atmosphere
lem, which is however limited to the strong forward Mie boundary “behind” the horizon – see Figure 3). In the previ-
scattering. In order to solve it we separate the single Mie ous example dH ' (Rt2 − R2g )1/2 for x and xs , while do ' dH
scattering term from all the others in S, so as to apply for x and dH − d for xs , which gives ∆uµ = 0.11 0.016
the phase function at runtime. For this we rewrite S̄[L̄] as for d = 100 km. With this mapping 128 samples for uµ are
PM S̄M [L̄0 ] + PR S̄R [L̄0 ] + S̄[L̄∗ ]. We then store CM = S̄M [L̄0 ] sufficient to avoid the above artifacts.
and C∗ = S̄R [L̄0 ] + S̄[L̄∗ ]/PR separately, which requires 6
Another problem is that S is discontinuous at the hori-
values per entry in S. If necessary, for efficiency, this can be
zon, due to the discontinuity of the length of the viewing
reduced to 4 values per entry by storing only the red com-
ray here. Hence a continuous mapping yields linear interpo-
ponent CM,r of CM . In this case the other components can
lations across this discontinuity, which causes artifacts. We
be approximated with a proportionality rule between S̄M [L̄0 ]
C βsR,r βsM solve this problem by ensuring that uµ is itself discontinuous
and S̄R [L̄0 ], which gives CM ' C∗ CM,r
∗,r βsM,r βsR
. at the horizon (see Figure 4). Finally, we use an ad hoc non
linear mapping for r and µs , chosen so as to get a better pre-
Parameterization In order to store S̄[L̄] into S we need a cision near the ground and for sun zenith angles near 90o .
mapping from (x, v, s) into table indices in [0, 1]4 . A simple So our mapping from (x, v, s) into [0, 1]4 is finally defined as
solution is to use r = kxk and the cosinus of the view zenith, follows:
sun zenith, and view sun angles, µ = v.x/r, µs = s.x/r and
ur = ρ/H
ν = v.s (mapped linearly from [Rg , Rt ] × [−1, 1]3 to [0, 1]4 ). √
uµ = 1/2 + (rµ + ∆)/(2ρ) if rµ < 0 and ∆ > 0
The problem of this parameterization is that it requires p
a very high resolution in µ to get a good sampling for the 1/2 − (rµ − ∆ + H 2 )/(2ρ + 2H) otherwise
aerial perspective. Consider for instance an observer near uµs = (1 − e−3µs −0.6 )/(1 − e−3.6 )
the ground looking horizontally, with a mountain at distance uν = (1 + ν)/2
d (see Figure 3). The aerial perspective is given by Equa-
tion 16 as S(x, v, s) − T (x, xs )S(xs , v, s). Then µ = 0 for x, with ρ = (r2 −R2g )1/2 , H = (Rt2 −R2g )1/2 , and ∆ = r2 µ2 −ρ2 .
the back faces (as seen from the sun) that are between this Acknowledgments This work was partially funded by the
plane and the sun [HHLH05]; Natsim ANR ARA project. We would like to thank Antoine
• we draw the terrain and the other objects with aerial per- Bouthors and Cyril Soler for proofreading.
spective, as well as the sky, using Equations 17 and 18.
If there are transparent objects such as clouds, aerial per- References
spective must be computed for each object, before blend-
ing. We use ∆n to compute occlusion in R[L0 ], and l˜ com- [BNL06] B OUTHORS A., N EYRET F., L EFEBVRE S.: Real-time
realistic illumination and shading of stratiform clouds. In Euro-
puted as above to get xs (see Section 5);
graphics Workshop on Natural Phenomena (sep 2006).
• we finally apply a global tone mapping function.
[DK02] DARULA S., K ITTLER R.: CIE general sky standard
defining luminance distributions. eSim (2002).
Results We run several tests with a height field and a re-
flectance texture from Nasa’s Earth Observatory [SVS∗ 05]. [HHLH05] H ORNUS S., H OBEROCK J., L EFEBVRE S., H ART
Results are depicted in Figures 8 and 9. As shown in Fig- J. C.: ZP+: correct Z-pass stencil shadows. In ACM Sympo-
ures 6 and 7 our model can reproduce with good accuracy sium on Interactive 3D Graphics and Games (I3D) (April 2005),
ACM, ACM Press.
the CIE clear sky model, fitted from actual measurements at
the ground level [DK02]. Since the sky color and aerial per- [HMS05] H ABER J., M AGNOR M., S EIDEL H.-P.: Physically-
spective are computed with a few texture fetches per pixel based simulation of twilight phenomena. ACM Trans. Graph. 24,
4 (2005), 1353–1373.
(< 10), our algorithm is quite fast. For instance, for the right
view in Figure 8 in 1024 × 768, we get 125 fps without light [HP02] H OFFMAN N., P REETHAM A. J.: Rendering outdoor
shafts on a NVidia 8800 GTS. This includes 5 ms for the un- light scattering in real time. Proceedings of Game Developer
shaded terrain, 0.4 ms for the first three terms in Equations Conference (2002).
17 and 18 and 2.6 ms for the remaining terms (including [IJTN07] I MAGIRE T., J OHAN H., TAMURA N., N ISHITA T.:
1 ms to evaluate the non linear parameterization). We get Anti-aliased and real-time rendering of scenes with light scat-
25 fps with light shafts (i.e., the first two rendering passes tering effects. Vis. Comput. 23, 9 (2007), 935–944.
cost a lot, about 32 ms). By comparison, we get 50 fps with [NDKY96] N ISHITA T., D OBASHI Y., K ANEDA K., YA -
our reimplementation of [O’N05], using ten samples per ray MASHITA H.: Display method of the sky color taking into ac-
(to get the same quality for single scattering, without shafts). count multiple scattering. In Proceedings of Pacific Graphics
(1996), pp. 117–132.
Limitations A limitation of our method is that the aerosol [NSTN93] N ISHITA T., S IRAI T., TADAMURA K., NAKAMAE
properties are assumed constant, depending only on altitude, E.: Display of the Earth taking into account atmospheric scatter-
whereas in fact they can greatly change depending on the ing. In SIGGRAPH 93 (1993), ACM, pp. 175–182.
atmospheric conditions [Slo02]. Since our precomputations [O’N05] O’N EIL S.: Accurate atmospheric scattering. In GPU
are very fast we can change these properties quickly, but they Gems 2: Programming Techniques for High-Performance Graph-
remain uniform. ics and General-Purpose Computation (2005), Addison-Wesley
Professional.
[PSS99] P REETHAM A. J., S HIRLEY P., S MITS . B. E.: A prac-
7. Conclusion tical analytic model for daylight. In SIGGRAPH 99 (1999).
We have presented the first real-time method to render the [REK∗ 04] R ILEY K., E BERT D. S., K RAUS M., T ESSENDORF
sky and the aerial perspective from all viewpoints, with mul- J., H ANSEN C. D.: Efficient rendering of atmospheric phenom-
tiple scattering, terrain shadows and light shafts, and correct ena. In Rendering Techniques (2004), pp. 374–386.
variation with all view and sun angles. This method is based [SFE07] S CHAFHITZEL T., FALK M., E RTL T.: Real-time ren-
on minimal simplifying assumptions that allow us to get an dering of planets with atmospheres. In WSCG International Con-
approximate solution of the rendering equation, in which ference in Central Europe on Computer Graphics, Visualization
most terms can be precomputed. This method can easily be and Computer Vision (2007).
extended to more complex physical models, with more con- [Slo02] S LOUP J.: A survey of the modelling and rendering of the
stituents or more wavelengths. Earth’s atmosphere. In SCCG ’02: Proceedings of the 18th spring
conference on Computer graphics (2002), ACM, pp. 141–150.
As future work we would like to model the effect of
[SVS∗ 05] S TOCKLI R., V ERMOTE E., S ALEOUS N., S IMMON
clouds on the ground illuminance and on the aerial per- R., H ERRING D.: The Blue Marble Next Generation – a true
spective, to remove the clear sky hypothesis. Indeed with color Earth dataset including seasonal dynamics from MODIS.
many clouds the interreflections between the ground and the NASA Earth Observatory (2005).
clouds should be taken into account [BNL06]. And their ef-
[TS99] T HOMAS G. E., S TAMNES K.: Radiative transfer in the
fect on aerial perspective should also be considered. To our atmosphere and ocean. Cambridge Univ. Press, 1999.
knowledge, this has never been done.
[ZWP07] Z OTTI G., W ILKIE A., P URGATHOFER W.: A critical
The source code of our implementation is available at review of the Preetham skylight model. In WSCG 2007 Short
http://evasion.inrialpes.fr/~Eric.Bruneton/. Communications Proceedings I (Jan. 2007), pp. 23–30.
1 1.6 3
0.8 1.5
0.4
0.6
1
0.4
0.2
0.5
0.2
0 0 0
-80 -60 -40 -20 0 20 40 60 80 -80 -60 -40 -20 0 20 40 60 80 -80 -60 -40 -20 0 20 40 60 80
View angle View angle View angle
4 6 10
Relative sky luminance (sun zenith angle = 30)
2 3 5
1.5 4
2
3
1
2
1
0.5
1
0 0 0
-80 -60 -40 -20 0 20 40 60 80 -80 -60 -40 -20 0 20 40 60 80 -80 -60 -40 -20 0 20 40 60 80
View angle View angle View angle
18 35 60
Relative sky luminance (sun zenith angle = 60)
10 20
30
8 15
6 20
10
4
5 10
2
0 0 0
-80 -60 -40 -20 0 20 40 60 80 -80 -60 -40 -20 0 20 40 60 80 -80 -60 -40 -20 0 20 40 60 80
View angle View angle View angle
Figure 7: Validation. The sky luminance relatively to the zenith luminance for several sun zenith and view zenith angles (and null azimuth be-
tween view and sun directions). Comparison between our model (with ᾱ = 0.1, βsM = 2.2 10−5 m−1 , βsM /βeM = 0.9, g = 0.73 and HM = 1.2 km)
and the CIE sky model 12 (based on actual measurements). We note an overestimation near the horizon (view angles near 90 and -90), which
is also visible in Figure 6. As shown in [ZWP07] the Preetham model [PSS99] also suffers from this problem, which probably comes from the
physical models currently used in CG.
Figure 8: Results. (a), from top to bottom: [SFE07], single scattering, multiple scattering and photo. With [SFE07] the shadow does not
appear due to the missing ν parameter. It is too dark with single sattering only. (b) sunset viewed from space. (c) the view used for our
performance measurements.
Figure 9: Results. Our results (no frames) compared with real photographs found on the Web (red frames). The tone mapping may explain
the sky hue differences on some images compared with the uncalibrated photographs.
Views from the ground showing, from left to right, the Earth shadow, the aerial perspective after sunset, sunset, and light shafts at sunrise.
Aerial perspective during the day, and mountain shadows for various view and sun angles.