###################################
Setting Up a HDR Rendering Pipeline
###################################

A full High-Dynamic-Range (HDR) rendering pipeline is using unclamped floating point data at all stages of the rendering. Then, the results of the rendering is scaled down to fit into the [ 0, 1 ] range of values that is used to submit data to the final Low-Dynamic-Range (LDR) output screen display:

.. figure:: hdr_pipeline.png
    :align: center

    **A typical HDR pipeline in an application**

In the example above, all the contents of the VRL#2 and VRL#1 are rendered using floating point buffers. Then, all results of the VRL#1 are rendered into VRL#0 that can be HDR or LDR, but that will always include a implicit HDR to LDR rendering pass before we can send the results to the display whose capabilities are only 8 bits per color components (or 10 bits for 30 bits screens).

The HDR to LDR phase is either performed using :doc:`/book/subjects/bk_re/bk_re_pp/bk_re_tone_mapping` or, if no tonemapping is enabled, by a clamp of all color values to the [ 0, 1 ] LDR range.

HDR can be turned on by two methods in HOOPS Luminate:

    * Create HDR VRLs directly using a floating point format:

.. code:: cpp 

    RED::Object* vrl;
    int width = 1920;
    int height = 1080;
    RC_TEST( iwindow->CreateVRL( vrl, width, height, RED::FMT_FLOAT_RGBA, true, iresmgr->GetState() ) );

Turn on HDR globally at the window level using the ``RED::OPTIONS_WINDOW_HDR``:

.. code:: cpp 
        
    RED::IOptions* iwinopt = window->As< RED::IOptions >();
    RC_TEST( iwinopt->SetOptionValue( RED::OPTIONS_WINDOW_HDR, 2, iresmgr->GetState() ) );

Note that a VRL in a window can override the option value using ``RED::IViewpointRenderList::SetHDROverride``, if it has to be LDR or HDR in a window that has a global option value that differs.