racer home

Atmospherical scattering


Home Adding atmosphere (literally and figuratively) to your tracks.

Dolphinity Organiser - free planning, project management and organizing software for all your action lists


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.

What is what?

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:

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>).

Dolphinity Organiser - free planning, project management and organizing software for all your action lists

(last updated November 13, 2012 )