Advanced Shadows in Real-Time

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

  • Ray-traced (hard) shadows

  • Soft shadows

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

Turning on Ray-Traced Shadows

All HOOPS Luminate 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.

../../../../_images/hard_ray_traced_shadows_gpu.png

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

Ray_traced Shadows from Skylights

The HOOPS Luminate’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:

../../../../_images/soft_ray_traced_shadows_gpu.png

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:

  • RED::OPTIONS_RAY_AREA_SHADOW_SPREAD: Determines how each sample will have an effect on its neighboring pixels.

  • RED::OPTIONS_RAY_AREA_SHADOW_SPACING: Determines the density of the shadow samples being cast.

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

../../../../_images/soft_and_hard_ray_traced_shadows_gpu.png