#############################
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:

.. include:: /tasks/ta_ca/ta_ca_light/tk_turning_on_ray_traced_shadows.rst

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.

.. figure:: hard_ray_traced_shadows_gpu.png
    :align: center
    
    **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:

.. figure:: soft_ray_traced_shadows_gpu.png
    :align: center
    
    **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:

.. image:: soft_and_hard_ray_traced_shadows_gpu.png
    :align: center
    