Setup a physical sun light

A physical sun light can't exist without a physical sky light. So all starts with the creation of a physical sky light (Setup a physical sky light).

Then the sky light is used to set up the sun light according to its sky model:

// "sky" is a pointer to a previously created and set up RED sky light instance.
RED::ISkyLightShape* isky = sky->As< RED::ISkyLightShape >();

// Initialize the sun light according to the current sky model settings.
RED::Object* sun = NULL;  // passing NULL makes the method below to create the sun instance for us.
RC_TEST( isky->SetSunLight( sun, iresmgr->GetState() ) );

Because the sun is a physical light, no other parameters are needed (like colour or intensity) and all other data are computed based on physics simulation. Finally, you can tune the quality of the sun light sampling by setting the sun samples count used during rendering:

// 64 samples are used to evaluate the contribution of the sun during rendering.
RED::ISunLightShape* isun = sun->As< RED::ISunLightShape >();
RC_TEST( isun->SetSamplesCount( 64, iresmgr->GetState() ) );

The sun is a relatively small source of light as seen from the earth. Hence, a few samples can be generally used to render it with good quality.

The effect of increasing the sun light samples count: 4 samples were used for the sun in the whole image except in the green zone where 16 samples were used.