The ‘Atmospheric Light Scattering’ (ALS) rendering framework
Have you ever admired the beautiful colors of a sunset? Have you maybe wondered why sometimes sunsets show a fantastic palette of glowing red and golden colors in the sky and sometimes a rather muted blue-grey? Have you observed distant hills fade into blue haze while the glittering reflection of the sun on water shifts color to a yellow-orange and asked yourself where the difference comes from? Have you wondered why there’s sometimes a halo visible around the moon?
All these phenomena and more are related to light scattering in the atmosphere. Actually, most of what we see looking out of a cockpit from 36.000 ft is not scenery but light scattered somewhere on haze, clouds or air molecules. To create a realistic impression of a scene during flight, we can’t think of haze being something simple that obscures the scene, instead we have to invest as much attention to rendering haze properly as to the more prominent scene elements. In Flightgear, that’s what the ALS framework is doing.
A little bit of theory
To first approximation, the normal lighting situation of a scene during daytime is that the sun is high in the sky and illuminates an object, from which reflected sunlight falls into the eye. There are thus two light rays – the illumination ray (I-ray) goes from the sun to the object and the observation ray (O-ray) from object to the eye.
In vacuum, that’s all there is to it, and pictures from the surface of the Moon illustrate this – objects remain visible no matter how far away, and any surface which is not in direct light is pitch black.
In an atmosphere, light scattering can affect both the I-ray and the O-ray, and there can be in-scattering and out-scattering. In-scattering corresponds to light from somewhere else in the scene being scattered onto the object (or into the eye), out-scattering corresponds to light from the sun being scattered away from the object or light from the object being scattered away from the eye. I-ray in-scattering causes ambient (non-directional) light – shadows are no longer pitch black but receive still some kind of illumination. Under a thin overcast haze layer, there is for instance strong I-ray in-scattering – while there is lots of light available, it comes from almost everywhere in the sky and no shadows are cast onto the ground. O-ray in- and out-scattering both cause objects being shrouded by haze, but in-scattering causes a bright haze, out-scattering a dark haze effect.
To complicate matters, there are three basic physical scattering mechanisms which can take place: Rayleigh, Mie and diffuse scattering.
* Rayleigh scattering occurs on very small particles – the air molecules themselves or fine dust (‘dry haze‘). It has no preferred direction, but is much stronger for blue light than for red light.
* Mie scattering occurs on larger particles – usually water droplets (‘wet haze‘). It has no color dependence, but is much stronger at small angles than at large angles, i.e. Mie-scattered light almost keeps its original direction.
* diffuse scattering isn’t really a distinct elementary process but the effect of multiple scattering processes over which direction and color specific dependence is blurred, hence diffuse scattering has no color or directional dependence.
Any real scene is hence a mixture of Rayleigh, Mie and diffuse in- and out-scattering on O-ray and I-ray (which makes for a total of 12 scattering channels, out of which 11 are modeled in at least some approximation by ALS – only Mie in-scattering on the I-ray is not considered since it is not very important in practice).
Wet and dry haze
Since most flight-relevant fog is wet haze, in FG the amount of wet haze is directly linked to the reported visibility. In many weather situations, fog is densest in the lowest convective air layer and the air is much cleaner above. ALS hence allows to render a lower layer of volumetric fog in addition to much less dense haze in the upper atmosphere. Seen from above (as in the scene showing morning fog at the foothills of Nanga Parbat), wet haze appears a bright white during the day, but when entering the fog, its color gradually changes to a dark blue-grey as diffuse out-scattering blocks the light.
The amount of dry haze (or Rayleigh scattering) relative to the wet haze is controlled by the air pollution slider in the weather configuration. Since Rayleigh haze is stronger for blue light, at large visibility O-ray in-scattering dominates (driven by the strong light coming from above) and far objects appear shifted towards sky-blue in color (such as the Sierra Nevada chain seen from China Lake below):
However, if the visibility is poor and/or the incident light from above is blocked, O-ray out-scattering is dominant, and all objects appear shifted to a dirty yellow – in other words, high air pollution makes objects appear in smog (here, downtown San Francisco):
The sky in low light
During the day, the I-ray is typically much shorter than the O-ray because the sunlight crosses the atmosphere vertically. The density of the atmosphere is variable in altitude, but effectively the whole vertical extent correspondsto a length of perhaps 10 km, whereas on a clear day objects 200 km distant can easily be seen. This is why Rayleigh out-scattering for the incoming light is not dominant while the sun is high.
In low light however, the I-ray passes a long distance through the atmosphere, the blue light is scattered out, and hence the direct light of the scene illumination is shifted to red (the indirect light however is driven by Rayleigh in-scattering and hence is shifted to blue). This can be seen here where the sun is below the horizon and illuminates the clear air close to the horizon whereas the lower haze layer is only visible in blue indirect light:
Without a lower haze layer, the whole scene appears in blue indirect light as seen here in the predawn Himalaya
As soon as the sun comes above the horizon and touches the highest peaks, strikingly beautiful contrasts appear between the blue indirect and the red direct illumination, leading to the phenomenon known as Alpenglow:
Looking away from the sun in low light, the clear atmosphere takes a deep violet color:
At very early predawn, just the far fringes of the upper atmosphere are illuminated. In clear air, the colors of dawn are muted:
In contrast, here a strong dry haze component leads to a sizable shift of the light to a red-golden color which lets the low wet haze layer glow brightly in the early morning light. While the light illuminating the wet haze is driven by Rayleigh scattering, the wet haze itself is a Mie scatterer – it glows most close to the sun, and the colors get more muted away – this is most evident from the thin clouds in the scene:
The combination of wet and dry haze can lead to nice and subtle color variations in low light:
The atmosphere seen from above
The following screenshots have been rendered with the EarthView orbital rendering option of FG in combination with ALS.
The characteristic electric blue glow of the atmosphere which is so prominently visible from low earth orbit is predominantly driven by Rayleigh scattering in the upper atmosphere.
Where the bulk of earth blocks the incoming light, Rayleigh scattering can no longer take place and the glow of the atmosphere gradually fades out:
The terrain itself is illuminated by light which has suffered Rayleigh out-scattering. In the dawn zone, this gives it again a color shift, here just slightly towards the yellow in this late afternoon impression of clouds hanging above the coast of Florida:
It is quite possible to observe the shadow earth casts into the atmosphere from lower altitude – here is an impression of it from 36.000 ft above an overcast cloud layer:
Clouds
Although they are rendered with rather different techniques, clouds physically are wet haze – thin translucent clouds are Mie scatterers, and thick clouds are diffuse scatterers. Thus, thin clouds light up very brightly in a halo when the sunlight is seen through them due to O-ray Mie in-scattering, whereas thick clouds appear dark and hide the sun due to O-ray diffuse out-scattering.
In predawn light, low clouds appear dark since they are yet in the shaded part of the atmosphere, but high Cirrus cloulds can already receive some sunlight:
As the sun comes up, this can lead to a dramatic play of light and shadow, with bright high-altitude clouds seen through a dark lower layer:
Again, the light that reaches the clouds at low sun is subject to I-ray Rayleigh scattering and its color depends on the amount of dry haze. In clean air, the colors of a cloud layer appear more muted
whereas for a high air pollution value the colors are much more strongly shifted towards the red-golden.
However, faraway cloud banks at the horizon can also reduce or alter the incident morning light by I-ray scattering. For thin, scattered clouds, this reduction is small and mornings appear bright
but if the cloud cover gets stronger, the light is reduced
and color shifted
to the point that a sunrise appears no longer red-orange-golden but blue-violet underneath a thick layer:
Diffuse haze in the atmosphere acts on the incoming light just the same way as a well-formed cloud layer – the light illuminating the clouds is reduced, and as the direct light is filtered out, the blue indirect I-ray Rayleigh in-scattering becomes more important, shifting colors to violet.
Compare the subtle play of dawn light shining through a cloud for a clear day
with a very hazy day with poor visibility aloft to appreciate the flattening of the color distribution:
Artificial light
At night, artificial light sources contribute a lot to the illumination – think of the orange glow of haze above a well-lit airport or a city. In principle, artificial light follows the same principles as sunlight, except that the intensity is usually far less, and so the paths through the atmosphere are smaller and effects are only visible in fairly dense fog. Then, often Mie-scattering can be observed, creating halos around lights seen through the fog.
Most of these effects are currently not included in ALS, however the Mie-scattering halos for runway lighting and the illumination of dense fog by landing lights are features already implemented:
Final thoughts
All the different scattering phenomena described above only scratch at the surface of what nature really does. In a real sunrise, clouds may cast shadows onto each other. There’s multiple scattering processes – a brightly illuminated haze layer high above may scatter lots of light down onto lower layers. There’s genuinely colored hazes like dust in a sandstrom which change the colors of dawnlight in yet different ways. There are effects of the human perception which make the eye see very faint or very bright light in colors different from what they actually are (which is why moonlight, despite being actually white light, appears as blue). While ALS tries to capture some of these processes, nature still does infinitely more, and sometimes one wonders how nature manages to get it all done in real time.
But even thinking about some of the phenomena causing it, you will never look at the play of haze and light the same way as before – be it in Flightgear or in reality.
All the screenshots above are rendered with the current development version of Flightgear (FG 3.3) out of the box. On a modern gaming laptop, in flight they typically render with 30+ fps (mainly dependent on visibility and LOD settings and the usage of hires scenery).
The ALS framework itself takes some 10 atmosphere-related input parameters to generate the visuals of the sky and of hazes, and this leads to an almost infinite variety. Unfortunately the majority of parameter combinations can not occur on Earth (ALS as such is quite capable of rendering a Martian sky), hence the raw input parameters are largely not under user-control. What limits the visuals ALS generates out of the box in practice is the actual range of parameters passed to the renderer by the weather simulation. Here, Advanced Weather using the offline weather engine is somewhat more faithful in generating reasonable light propagation models in the lower atmosphere than Advanced Weather in METAR mode, which is in turn better than Basic Weather, but even Advanced Weather currently exhausts just a fraction of the possibilities ALS really offers.
Modeling a compelling haze distribution and the resulting light attenuation in real time is a genuine challenge, since it is impossible to actually do the scattering calculations (which involve nested integrals) in anything resembling real time, so in every case, fast yet faithful approximations have to be found.
To experiment some with sunrises, try various weather scenarios and play with the lower haze settings and the air pollution on the Advanced Weather options panel.
You must be logged in to post a comment.