Sky / Atmospheric Rendering
subsections: Clouds, Fog, Rain, and
Lighting
Sky Color
- Sky dome
- A common approach is to model a dome, and either apply a texture map
or use vertex colors to provide the impression of a sky.
- a texture map dome can be extremely realistic looking,
but has drawbacks:
- difficult to make it change with time of day
- if it contains pictures of clouds, they must be very distant clouds,
otherwise as the viewer moves around a landscape, they would notice
the same clouds staying overhead
- vertex color dome
- in general, daytime sky color is a gradual fade from "horizon color"
to "zenith color" overhead
- for example, a clear blue sky usually goes from a light cyan at
the horizon to a rich medium-blue
- at dusk and dawn, there is an additional fade of warm color from
a broad stretch of the east/west horizon to the zenith, as shown in
the photograph to the right
- by choosing an attractive set of colors, you can just interpolate
between them for all times of day and night
- the colors of a sunset are typically: yellow at the edge, then orange-red,
then purple-slate blue
- Sky Domes
Tutorial at the game developer site Flipcode
- includes source code
- uses blending of luminosity textures, draws a flare around the sun
- The Brightness
of the Night Sky answers questions such as "How do man-made light pollution,
natural air glow and light from interplanetary dust affect the darkness of the
night sky? What about elevation, transparency and atmospheric particles?"
Some academic work
- Precomputed
Atmospheric Scattering (pdf)
- Eric Bruneton and Fabrice Neyret, EGSR 2008
- Abstract: "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 [..] 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"
- there is a
demo with full source code (including GLSL)
- I was able to build and run the demo, and although it is not the full
algorithm from the paper (no elevation, so no light shafts) the effect is
fast and very nice, especially sunset/sunrise.
- Implemented in the open-source terrain library
Proland.
-
Real-Time
Rendering of Planets with Atmospheres (pdf)
- T. Schafhitzel, M. Falk, T. Ertl, In Journal of WSCG 07, 2007
- From the abstract: "A real time technique for planetary rendering and
atmospheric scattering effects. Based on Nishita's atmospheric model, taking
into account air molecules and aerosols, and on a CLOD planetary renderer.
Interactive frame rates by combining the CPU bound spherical terrain with
the GPU computation of the atmospheric scattering."
-
Real Time Rendering of Atmospheric Scattering Effects for Flight Simulators
(pdf)
- Ralf Stokholm Nielsen, Sept. 2003
- an excellent overview of the whole field of atmospheric rendering, and
well-documented implementation of realistic effects using vertex-shader
programming
-
A
Practical Analytic Model for Daylight
- A. J. Preetham, Peter Shirley, Brian Smits, Siggraph 99
- goes into rigorous depth: "Sunlight and skylight are rarely rendered
correctly in computer graphics..."
-
A fast, simple method to render sky color using gradient maps, 2006
- method and whitepaper by Jesús Alonso Abad, aka Kencho
- uses a single texture to hold the color gradient for a whole day, with
the texture U coordinate for time
- there is a related open-source addon for the Ogre3D engine, called
caelum
- Display
Method of the Sky Color Taking into Account Multiple Scattering
- Tomoyuki Nishita, Yoshinori Dobashi, Kazufumi Kaneda, Hideo Yamashita,
Pacific Graphics '96
- a fast method to calculate the spectral distribution of sky radiation
for single scattering, and an efficient method to calculate the sky color
taking into account multiple scattering.
- Nishita seems to be the most-referenced author in this field.
Many recent papers involve implementation of his atmospheric model, with
optimizations like using the GPU.
- Erweiterung und Verbesserung eines strahlenphysikalischen
Ansatzes zur Simulierung der Globalstrahlung und ihre Anwendung bei der Visualisierung
windbewegter Wasseroberflächen (German only, no longer online?)
- Bertram Walter, between 1996 and 2000
- Google translates the title as "Extension and improvement of a radiate-physical
beginning for simulating the global radiation and their application with
the visualization of wind-moved water surfaces" and does a reasonable job
on the paper itself
- reportedly an excellent treatment of the subject of atmospheric optical
modelling
-
GPU-based
multi-layer perceptron as efficient method for approximation complex light models
in per-vertex lighting
- Konrad Pietras, March 2005
- "display method of the sky color on GeForce FX hardware", with plenty
of math, source code, and resulting images
- On Athlon 1700+, GeForce FX 5500, in 1280x1024x32 resolution, the program
runs with speed of 9 - 11 frames per second.
Sky Rendering Libraries
- SilverLining is a cloud rendering
library which also includes some very extensive sky rendering: sky color, sun,
moon, stars, lightning, etc. More about SilverLining on the
Clouds page.
- The VTP software has some support for sky
dome color, sun, moon and stars.
- The sun is positioned correctly based on earth location and date/time
using SPA.
- The sky color is implemented with vertex colors, allowing for a sunrise/sunset
glow in the east and west.
- The sun and moon are implemented as texture quads, the stars as OpenGL
points.
- Alternately, the sky dome can use a static texture, upon which the sun
glow is rendered additively. This is the most photogenic approach
because a sky photograph with clouds, etc. can be used.
- osgEphemeris
is a nodekit for OSG which implements
sky dome color, sun, moon, and stars
- Rendered very efficiently with OpenGL and GLSL, positioned correctly
based on earth location and date/time.
- The sky color is implemented with a 1D texture, so color is the same
in all directions.
- The sun is a texture quad, the moon is a full 3D spherical model, the
stars are a GLSL shader.
Sky dome textures
- SkyPaint ($85) is a small program
for painting panoramic sky images
- Philo's Sky Collection
has 16 nice, free skydomes
- Continuum has over 25 nice, free skydomes
including some 'fantasy' skies, even an animated skydome
- Roel Reijerse's skyboxes
contains 4 very nice free skies, although they are in the alternative "box"
layout which loses 1/2 of the area to blank space and another 1/4 to the blank
area below the horizon.
- Blender Textures:
Sky has some free sky textures (CC-by-nc-sa
license, but the owner says "the only restriction is that you can't sell them")
- Here are the realistic skies from that page, resized to 4096x1024 for
use in the VTP software, just drop them into your "Data/Sky" folder:
Sky_madcow_4096.zip (1.3 MB)
- Or resized to 2048x512 for older ATI cards:
Sky_madcow_2048.zip (477 KB)
Sun & Moon
- computer displays don't have the dynamic range
to actually draw a bright object like the sun
- one thing you can do is put a "glow" in the sky
- using a intensity map, an additive texture map, or a solid white texture
with a gradient alpha map, as in the example to
the right (128x128 TGA):
- lens flare effects might help
- using an "additive" texture map allows it to blend smoothly into the
sky dome
- for the moon, brightness isn't as much of an issue, since it isn't much
brighter than a CRT is capable of
- again, a well-designed additive texture map would probably give the
expected result, even when the moon appears in the day against a blue sky
- however, in order to show phase of the moon, might want to try a physically
modelled sphere and let the rendering library light the illuminated region
- the size of the sun and moon in the sky is almost exactly the same
- diameter, distance of sun: 1400130 km, 149597870 km
- diameter, distance of moon: 3474.8 km, 384401 km
- diameter of earth: 12756 km
- angular size of objects as seen from earth = arctan( diameter/distance
)
- sun diameter/distance: 0.00936 = 0.53623 degrees as seen from earth
- moon diameter/distance: 0.00904 = 0.51791 degrees as seen from earth
- A Physically-Based
Nightsky Model
- Henrik Jensen, Frédo Durand, et. al., Siggraph 2001
- describes the physical basis for combining light from the stars, moon,
atmosphere, and 'zodiacal light'
- includes a BRDF for the Moon!
- from the
flipcode tutorial:
- "The moon has to be rendered in 2 passes. First, from the moon texture,
which also has an alpha component, a mask is generated that has alpha values
of 1.0 for texels inside the moon and alpha values of 0.0 for texels outside
the moon. This mask is rendered onto the dome without blending using the
current sky color. This is done to remove any stars that might appear behind
the moon. Next, the actual moon texture is blended onto the sky dome. The
reason it is blended is because during the day, the moon will show a bit
of blue or red hue of the sky."
-
Placing
the Sun, Moon and stars correctly in the sky requires understanding Celestial
Coordinates
- How to compute the positions for the Sun, Moon and the major planets
- Sunlit Designs
InfoSearch is a very nice glossary of sun/solar terminology
- they also produce the
Sun
API, a Solar and Sundial Calculation freeware program (free)
Stars
- Star location data is available from the public-domain
bright star catalog
(BSC) in celestial coordinates, which are a kind of polar coordinates
- One formula for conversion of declination and right ascension (abbreviated
as (dec, ra)) to (x, y, z) are:
- x = -cos (dec) * sin (ra);
- y = cos (dec) * cos (ra);
- z = sin (dec);
- Setting a maximum magnitude (minimum brightness) of:
- 5.5 gives 2887 stars
- 5.8 gives 4103 stars
- As these magnitudes are barely visible under the best of conditions, you
can see that a relatively small number of stars is sufficient to draw an accurate
sky
- Excellent article
High-quality rendering of 2.0 stars (via google translate, or see the
original in German:
Hochwertiges Rendern von Sternen) by Chris Maiwald, 2009
Rainbows
|
|
- first rainbow: red on outside, violet inside
- the second rainbow of a double rainbow: red inside, violet outside, fainter
and wider
- at what angle, relatives to the sun's direction, does the rainbow appear?
- wikipedia Rainbows gives
the answer as 40-42° for the primary and 52-54.5° for the secondary rainbow
- the sky inside the rainbow is slightly lighter
- Light
and Optics weather site gives detail on other atmospheric effects such as
halos and
sundogs
- Prisms and Rainbows:
A Dispersion Model for
Computer Graphics (ps, Musgrave 1989) gets deep into the math and physics
of the rainbow
- Clint Brewer's technique (GDC 2004): NVidia technical report: How to
render a real Rainbow.
- That's no longer online, but there is
NVidia SDK Sample: Rainbow Fogbow (user guide / whitepaper / sample
code), which is the same material
- Covers the basic physics of Rainbows, Fogbows and Coronas, how to implement
them using a pre-calculated lookup texture in a programmable shader, and
blend them realistically with a 3D scene.
General Atmospheric Rendering
- Night Rendering,
University of Utah, covers the moon and stars and the impact of nighttime lighting
conditions to the terrain scenery
- Jaroslav Sloup's Modeling and
Rendering of Atmospheric Effects project at CCG Prague (2000-2003), covered
the color of the sky, plus "halos, mirages, green and red flashes, rainbows,
etc.", seems to be gone as of 2007
Atmosphere from Space
-
the
earth's atmosphere looks different from space
- "Display
of The Earth Taking into Account Atmospheric Scattering"
- Nishita, Sirai, Tadamura, Nakamae, Siggraph 93
- algorithm for efficient calculation of optical length and sky light
-
Real-Time Atmospheric Scattering, GameDev article by Sean O'Neil
- describes how to do a fast, practical implementation of the Nishita
approach
- ORBITER Space Simulator (free,
but closed source) demonstrates the nice effects of using a land/water mask
for surface reflectance of the earth, as well as atmospheric haze and cloud
shadows on the surface:
- Sean O'Neil's project site 'A Real-Time Procedural
Universe' contains demo apps (with full source) using OpenGL with GLSL to
render Atmospheric Scattering both from space and from within the atmosphere:
I didn't have much luck running his Planet_Quad demo a few year back (with a
ATI Radeon 9800) but it might work fine for your system
Open-source Apps
- Stellarium and
Celestia are open-source applications
that do full sky and star rendering, so perhaps parts of them could be adapted
for use in terrain rendering application