Table of Contents

Atmospheric Scattering Component

The Atmospheric Scattering component computes the sky procedurally from a physical model of a planet's atmosphere. It reacts to the sun direction, so sunrises, sunsets and day-night cycles come out of the same set of parameters. The model contains Rayleigh scattering (air molecules, responsible for the blue color), Mie scattering (aerosols such as dust, water droplets and pollution, responsible for haze and the bright halo around the sun), ozone absorption (keeps the sky blue during twilight) and multiple scattering.

Sky

Setup

  1. Create a game object and attach an Atmospheric Scattering component. The yellow arrow shows the direction in which the sunlight travels.
  2. Rotate the object to position the sun. The light travels along the object's positive X axis, which is the same convention as for the directional light. Put a directional light component on the same object, so that the sun in the sky and the scene lighting always match. With SetLightColor enabled, the atmosphere also sets the color of that light, see below.
  3. For ambient light from the sky, add a sky light to the scene and give the atmosphere object the tag SkyLight. If the sun moves at runtime, set the sky light to Dynamic, otherwise it only captures the sky once.

Performance

The scattering is precomputed into lookup tables on the GPU. Thus drawing the sky is relatively cheap. However, the tables need to be recomputed when the sun direction or any of the properties change, which is much more expensive. It is possible to do fully dynamic day-night-cycles this way, but it has considerably larger performance impact than keeping the sky static.

Common properties

  • SunIntensity: Brightness of the sky. This is no physical unit, the value has to be balanced against the camera exposure and the brightness of the directional light.
  • SunDiscSize: Angular diameter of the visible sun disc. The real sun is about 0.5 degrees, but a larger disc often looks better in games. Zero disables the disc.
  • SunDiscIntensity: Brightness of the sun disc, before it is attenuated by the atmosphere. Close to the horizon the disc automatically becomes darker and redder.
  • SetLightColor: If enabled, the color of the sunlight is computed and sent to the object every frame (as an ezMsgSetColor message). A directional light on the same object takes it over and its own LightColor property is overwritten. Because the light is never fully white, its intensity may need to be raised a bit. Disable this option to choose the light color yourself.
  • GroundHeight: The world space Z coordinate of the planet surface. Moving the camera upwards makes the sky darker and the horizon lower, but only noticeably at heights of several kilometers. For a scene in the mountains, set this to the negative altitude of the scene (for example -3000 m), instead of lowering AirDensity. Then the air and the haze both get thinner by the correct amount, about 0.82 times at 1600 m and 0.69 times at 3000 m.
  • UseFog, VirtualDistance: If enabled, fog is applied to the sky. VirtualDistance is the distance used to compute how foggy the sky appears. Same as for the skybox component.

Atmosphere properties

These properties control the look of the sky. Start with a preset and adjust AirDensity and Haze, before changing any of the physical parameters.

  • Preset: Selects a predefined set of planet and scattering parameters:
    • Earth: The default. Earth at sea level with clean air. Uses the measured values from Sébastien Hillaire's paper "A Scalable and Production Ready Sky and Atmosphere Rendering Technique" (2020). These are also the defaults of the Custom properties.
    • EarthHazy: Humid or polluted air. The whole sky is milky and the sun has a large halo.
    • EarthClear: Even cleaner air, as after rain or in the mountains. Deep blue sky with a small, sharp halo around the sun.
    • DustyPlanet: A smaller planet with a thin, dusty atmosphere and an orange sky. This only resembles Mars and is not physically accurate (see limitations).
    • Custom: Uses the values from the Planet and Scattering groups. These groups are only shown when Custom is selected. When switching to Custom, the previous custom values are restored, the values of the preset are not copied.
  • AirDensity: Multiplier for Rayleigh scattering and ozone absorption. Values above 1 give a deeper blue sky, a darker zenith and redder sunsets. Values below 1 give a paler sky, zero removes the air entirely, leaving only the haze. A value of 1 is the air at sea level in the standard atmosphere (15 °C, 1013 hPa). On Earth the air density hardly changes: the weather changes it by about 3% and the temperature by about 10%, cold air being denser than warm air. So realistic values are between about 0.85 and 1.15, and the difference is barely visible. Cities don't have denser air, they have more aerosols, which is Haze.
  • Haze: Multiplier for Mie scattering and absorption. Values above 1 make the sky hazy and the horizon bright and white, and widen the halo around the sun. Zero gives a perfectly clean sky. This value usually needs the biggest adjustments to get a certain mood. Unlike the air density, the amount of aerosols on Earth varies a lot from day to day: roughly 0.3 to 0.5 is clean air after rain, 1 is a normal day, 3 to 10 is a hazy summer afternoon or a city, and higher values give heavy smog.
  • GroundAlbedo: The color of the ground below the horizon. It is visible where no geometry covers the horizon and through multiple scattering it also tints the lower part of the sky. Bright values (snow, sand) brighten the horizon. This is applied for all presets.

Planet and scattering properties

These are only used with the Custom preset. All coefficients are given at ground level, in units of 1/Mm (per 1000 km, which equals 10-6 per meter). Values given per meter in the form 5.802e-6 are entered as 5.802. Values per kilometer, as used by Unreal Engine's Sky Atmosphere component, have to be multiplied by 1000 (where Unreal splits a coefficient into a scale and a color, multiply both).

  • PlanetRadius: Radius of the planet in kilometers. Mainly affects the sky close to the horizon and how long twilight lasts.
  • AtmosphereHeight: Thickness of the atmosphere in kilometers. Must be several times larger than the scale heights below, otherwise the atmosphere ends abruptly.
  • RayleighScattering: Scattering of air molecules per color channel (red, green, blue). The ratio between the channels determines the color of the sky, the overall magnitude its brightness and how quickly sunlight gets red when the sun is low. For real gases, blue is always scattered most.
  • RayleighScaleHeight: Height in kilometers at which the air density has dropped to 37% (1/e) of its ground value.
  • MieScattering: Scattering of aerosols. It is the same for all colors, so it only adds white haze.
  • MieAbsorption: Absorption of aerosols. It is the same for all colors as well. It makes the haze darker and greyer and dims the sun, without adding any light. Soot and dust absorb a lot, water droplets very little. For typical Earth aerosols it is about 10% of MieScattering.
  • MieScaleHeight: Like RayleighScaleHeight, but for aerosols. On Earth most aerosols stay close to the ground, so this value is much smaller.
  • MieAnisotropy: How much aerosols scatter light forwards. Values close to 1 concentrate the light in a small bright halo around the sun, 0 scatters the same amount in all directions. Negative values scatter backwards and are rarely useful.
  • OzoneAbsorption: Absorption of the ozone layer per color channel, at its densest point. Ozone absorbs mostly green and red light. Without it, the sky becomes yellowish during twilight. The ozone layer has a fixed shape: it starts at 10 km, is densest at 25 km and ends at 40 km. AirDensity scales it as well.

Designing a custom atmosphere

Rules of thumb for an alien atmosphere with the Custom preset:

  • Sky color: The channel with the largest RayleighScattering value is the color of the sky at daytime. Sunsets get the color of the channel with the smallest value, since that light makes it through the atmosphere. To get an orange sky, the red value has to be the largest, which no real gas does, but it gives a convincing look.
  • Thin atmosphere: Lower the scattering values or AirDensity. The sky gets darker and the sun stays white at the horizon.
  • Thick atmosphere: Higher values make the sky brighter towards the horizon and the sun turns red and disappears well before it reaches the horizon.
  • Dust storm: Increase Haze strongly and set MieScaleHeight to several kilometers, so that the dust is not only near the ground.
  • Smaller planet: Lower PlanetRadius and the scale heights together, keeping their ratio similar, otherwise the horizon looks wrong.

Limitations

  • The sky can't be viewed from space. Camera heights above the atmosphere are clamped.
  • Mie scattering and absorption are the same for all colors. Real dust, as on Mars, absorbs blue light and scatters differently per color, which gives the Martian sky its butterscotch color and the blue sunsets. This can't be reproduced exactly, the DustyPlanet preset fakes the color through the Rayleigh coefficients instead.
  • The height and shape of the ozone layer are fixed.
  • The model has no clouds.

See Also