Home | Adding atmosphere (literally and figuratively) to your tracks. |
|
Introduction
The default OpenGL fog method has been useful, but these days things can get much nicer. Racer enables the use of atmospheric scattering to get beautiful sky gradients. Keywords here are rayleigh scattering, mie scattering and aerial perspective. Below is an example at 19:30 with some Mie scattering (haze).
NOTE: most of the parameters here are now (v0.8.23+) driven by TOD (time of day) curves. See here for more information on setting time of day parameters.
The theory
Background material that explains more about Rayleigh & Mie scattering due to atmospheric particles and air follows. You may skip this, since it isn't necessary to understand technical implementations to use the atmosphere system.
More links on atmosphere and sky rendering van be found at VTerrain.
In short, the atmosphere bounces light back & forth, which gives the sky a non-black appearance (blue in fact ;-) ). Roughly spoken, two types of scattering exist:
Aerial perspective means that as you look further away, the sky and geometrical elements (track objects) blend further into each other. So distant objects become blueish on a clear day.
Racer supports all this since v0.7.2.
To apply an atmosphere to a track, you have to be aware of the different components:
The steps
In short, the steps for adding an atmosphere are:
Add a skydome to your track. For example, if you have a skydome named sky.dof, add this to geometry.ini:
sky
{
file=sky.dof
; Move with camera to avoid pop
flags=64+8
}
shader_sky~vf_sky { sky=1 layer0 { map=sky_sun_alpha.tga texenv=replace depthwrite=0 } }
vf_sky { vertex_shader { file=sky_v.cg } fragment_shader { file=sky_f.cg } }
Modifying special.ini
In special.ini, take note of the following parameters dealing with atmosphere:
Parameter | Description |
gfx.fog.rayleigh | Amount of Rayleigh scattering. Start with 0.0025. This accounts for the blue color of the sky. |
gfx.fog.mie | Amount of Mie scattering. Start with 0.001. This accounts for haze, or fog. Use 0.01 for example for a quite foggy environment. |
gfx.sun.intensity | The sun intensity. Start at 1.0 (versions below v0.8.9 used values around 2000). |
gfx.exposure | Exposure amount. Start at 1.0 (recommendation was 50 in older versions!). |
To play around, just start the track and use the script command 'fog rayleigh <v>', 'fog mie <v>', 'sun intensity <v>' and 'exposure <v>'. Also use the 'time' command to try various times of day to see how things hold. After finding suitable values, insert them into the special.ini file (in data/tracks/<mytrack>).
(last updated November 13, 2012 )