3D clouds

From FlightGear wiki
Jump to navigation Jump to search
3D clouds in OSG with shaders.
Development version 3D clouds in OSG with shaders.
3D clouds in OSG version as seen from a EC135.
3D clouds in PLIB version
Clouds back in 2001

FlightGears weather system uses 3D clouds for a realistic reproduction of the sky. 3D clouds have been present since version 0.9.1, and significantly updated in version 0.9.9.

FlightGear 2024.X uses "billboarded" clouds that can be defined in XML. Post 2024.X, FlightGear uses fully rendered voxel-based clouds.

Voxel-based clouds (post 2024)

Voxels are 3D pixels. Imagine a rubix cube, then each of the 3x3x3 cubes is a voxel.

The voxel texture is a 3D texture of WxWxH voxels.  It is stored as a PNG file. As PNG files are two dimensional, the file is chopped up to make the 3D texture. So a file of of height W and width WxH, is chopped into WxW slices to create the 3D texture.

Rather than describing the cloud colour, the RGBA channels of the texture are used as follows:

  • R - Dimension.  This is a positive gradient with 1.0 at the center of the cloud, and 0.0 at the edge.
  • G - Type.  From wispy (0.0) to billowy (1.0)
  • B - Density.  0.0 is no cloud density, 1.0 is fully opaque density.  Use this to determine if there is any cloud at this location.
  • A - Signed Distance Field in UV space.  The maximum radius sphere centered on this point that doesn't contain any cloud density.  Used for adaptive ray marching.  Negative values represent areas inside the cloud.


However, the PNG file should only set the G and B channels, as the R and A channels are calculated by FlightGear itself.

See examples in fgdata/Textures/Sky

Billboarded Clouds (2024.X)

Note: the cloud XML format in CVS is currently undergoing renovation to allow more control, and more natural looking clouds.

A 3D cloud layer is defined in the <layers> section. It contains of a number of randomly located <boxes>, containing a set of <clouds>.

Each cloud is generated with random size, based on the following tags:

<min-cloud-width-m>
<max-cloud-width-m>
<min-cloud-height-m>
<max-cloud-height-m>

The cloud consists of <num-sprites> individual sprites. Each sprite is generated with random size, based on the following tags:

<min-sprite-width-m>
<max-sprite-width-m>
<min-sprite-height-m>
<max-sprite-height-m>

The <texture> defines the texture file to be used for the sprite. The texture file may contain more than one texture in a grid, by setting the <num-textures-x> and <num-textures-y> tags.

Clouds are darker towards the bottom. bottom-shade indicates the shading factor of the bottom of the cloud compared with the top.

Finally, note that the clouds are defined as a set of properties, so they can be modified within the simulator under /environment/cloud-layers. You can then see the effects of your changes by changing the clouds dialog, which reloads the clouds from properties.

Cloud Textures

Advice for those editing cloud textures:

  • Place a black layer behind the clouds you are editing. This makes it easier to see the white clouds, and in particular spot posterization. Note that GIMP appears to have a bug in that simply changing the transparency colour to black under Preferences->Display changes the background to black.
  • Display a grid of the appropriate dimensions to ensure you don't draw clouds over the texture boundaries. Otherwise the clouds can bleed into each other and you can see nasty vertical and horizontal edges.
  • Use a white airbrush and a smudge tool to make the cloud textures look random.

External links