Advanced shadows in real-time

REDsdk natively supports other types of shadows than shadow maps in hardware rendering. REDsdk uses the GPU (and all CPU cores available too) to produce:

Both shadowing methods require ray-traced shadows to be enabled for the light:


Task: Turning on ray-traced shadows

All REDsdk lights do support ray-traced shadows (exception made of the ambient light of course, but can we call it a real light?). Ray-traced shadows may produce hard shadows or soft shadows, depending on the light source geometry: all centric or directional lights that have no light emitting surface will produce hard shadows. All lights sources that have a light emitting surface will produce smooth shadows.

Ray-traced shadows can be enabled using the following code:

// Disable shadow mapping that has precedence over ray-traced shadows and turn on shadows on the light:
RED::ILightShape* ilight = light->As< RED::ILightShape >();
RC_TEST( ilight->SetShadowMapping( false, iresmgr->GetState() ) );
RC_TEST( ilight->SetRenderMode( RED::RM_SHADOW_CASTER, 1, iresmgr->GetState() ) );

Shadow mapping must be disabled, as whenever enabled, it'll override ray-traced shadows. Then, the light needs to cast shadows and that's all.

And then, ray-tracing options need to be turned on. For shadow casting purposes, we need the RED::OPTIONS_RAY_SHADOWS to be set to 1 or higher.

Ray-traced shadows from centric lights

Centric or directional lights have no surface. Consequently, they produce hard shadows. The casting of ray-traced shadow does not require any parameter to be set to work (exception made of shadow bias that can be specified; see RED::ILightShape::SetShadowBias). This makes it a lot simpler to use than shadow mapping.

Performances are not as good as shadow mapping, but remain interactive on most computers.

An example of hard ray-traced shadows running at 10 FPS on an average computer

Ray_traced shadows from skylights

The REDsdk's hardware accelerated ray-tracing engine can render soft shadows cast by skylights in real-time, as illustrated below. Again, no specific setup is required. Ray-traced shadows need to be turned on and a skylight need to be present in the scene and voila:

Soft ray-traced shadow cast by a GPU skylight at 2-3 FPS

GPU ray-traced shadows cast by a skylight area based on Monte Carlo sampling, implemented on the GPU. The quality of the skylight GPU ray-traced shadows is ruled by:

Assembling both sources of light result in the following GPU image: