Adding clouds to the sky texture

Until now, the sky was empty. In real life, a perfectly clear sky is very rare. We have to add clouds to it!

Empty sky is very rare

Adding clouds to the sky

REDsdk provides a really simple function to add several types of clouds to the sky texture:

This method defines a cloud layer that will be added to the sky texture. It must be called after a sky has been defined and before the texture is created.

task

Task: Adding clouds to a sky light shape

To add clouds to the sky light shape, simply call the RED::ISkyLightShape::AddClouds function after the creation of the sky. The clouds will appear on the final sky texture. The texture can later be added as background image.

RED::ISkyLightShape* isky = sky->As< RED::ISkyLightShape >();

// Setup the sky model.
RC_TEST( isky->SetPhysicalModel( 1.0, view_height, 1.0, 3, 0.1, 0.8, 0.7,
                                 sun_direction, 1.0, 1.0,
                                 moon_direction, 1.0, 1.0, 
                                 1.0, 0.6, iresmgr->GetState() ) );

// Add the clouds layer.
int cloudlayer;
double cumulus_altitude = 1000.0;
double cumulus_density = 0.2 * 1e6;
double cumulus_intensity = 1.0;
double cumulus_opacity = 0.8;
RC_TEST( isky->AddClouds( cloudlayer, cumulus_altitude, cumulus_density, cumulus_intensity, cumulus_opacity, RED::CT_CUMULUS, 18081986, iresmgr->GetState() ) );

// Setup the background image.
RC_TEST( isky->CreatePhysicalSkyTexture( bg_tex, true, 0, false, true, true, iresmgr->GetState() ) );

For further explanations about the sky light shape, see Sky model.

Several cloud layers can be added to the sky. Each one defining a type of cloud (see RED::CLOUDS_TYPE and later on this page). To combine multiple layers, simply call RED::ISkyLightShape::AddClouds as many times as needed layers. The RED::ISkyLightShape::ClearClouds function allows to delete all the clouds layers that were previously added.

Different kind of layers: cirrus, stratus, cumulus and all three cumulated

The function parameters allows to parameter the cloud layer by defining:

Changing the view height and the sun direction of the sky model affects the clouds visualization. Clouds can be seen from below as well as from top and from inside the layer. The clouds color and intensity change according to the sun direction.

Clouds inside view and top view on sunset

Note:

Cirrus layer is a simple texture. It means that it is always rendered from below. Setting an altitude for this layer type is useless.

Updating clouds

Once a clouds layer have been created, it can be edited by calling the RED::ISkyLightShape::UpdateClouds function. Giving the layer index, this function will allow to change the altitude, intensity and opacity of the layer without having to recompute the clouds shape.

A few remarks about REDsdk background clouds system

List of REDsdk clouds type

REDsdk provides different kind of clouds appearance via its RED::CLOUDS_TYPE enumeration.

Cumulus

These are high density puffy clouds with clearly defined edges. They appear at low altitude (less than 2000 m).

RED::CT_CUMULUS appearance

Stratus

Stratus are flat hazy clouds with low density. They appear at middle altitude (from 2000 to 7000 m). The opacity of the clouds layer should be decreased for these types of clouds.

RED::CT_STRATUS appearance

Cirrus

These are thin, wispy clouds at high altitude. In REDsdk, they are rendered using a simple texture applied to the background sky.

Several cirrus textures are available as shown in the following pictures.

RED::CT_CIRRUS_1 appearance

RED::CT_CIRRUS_2 appearance

RED::CT_CIRRUS_3 appearance

RED::CT_CIRRUS_4 appearance

RED::CT_CIRRUS_5 appearance