#################################
Enabling Intel Open Image Denoise
#################################

Here is how to activate the denoising using Intel Open Image Denoise:

    * first, make sure the libraries are beside HOOPS Luminate libraries
    * then enable it like this:

.. code:: cpp 

    // 1. Get the options interface from a viewpoint or the window.
    RED::IOptions* options = viewpoint->As< RED::IOptions >();

    // 2. Enable Open Image Denoise.
    RC_TEST( options->SetOptionValue( RED::OPTIONS_RAY_ENABLE_OPEN_IMAGE_DENOISE, true, iresmgr->GetState() ) );

    // 3. That's all!

If ``RED::IWindow::FrameTracingImageLayers`` is used instead of the classical ``RED::IWindow::FrameTracing``, the diffuse and normal layers are used to improve the denoising.

.. code:: cpp
        
    // Denoising is improved by providing diffuse and normal buffers with RED::IWindow::FrameTracingImageLayers
    RED::Object *imageColor, *imageDepth, *imageDiffuse, *imageNormal;
    RC_TEST( iresmgr->CreateImage2D( imageColor, iresmgr->GetState() ) );
    RC_TEST( iresmgr->CreateImage2D( imageDepth, iresmgr->GetState() ) );
    RC_TEST( iresmgr->CreateImage2D( imageDiffuse, iresmgr->GetState() ) );
    RC_TEST( iresmgr->CreateImage2D( imageNormal, iresmgr->GetState() ) );

    RED_RC rc;
    RED::Vector< RED::RenderLayer > render_layers;
    // Color and depth layers are mandatory.
    RED::RenderLayer layer1( RED::RenderLayer::LT_COLOR, imageColor, viewpoint, rc );
    RC_TEST( rc );
    RC_TEST( render_layers.push_back( layer1 ) );

    RED::RenderLayer layer2( RED::RenderLayer::LT_DEPTH, imageDepth, viewpoint, rc );
    RC_TEST( rc );
    RC_TEST( render_layers.push_back( layer2 ) );

    // Diffuse and normal layers are optional and improve the denoising.
    RED::RenderLayer layer3( RED::RenderLayer::LT_DIFFUSE, imageDiffuse, viewpoint, rc );
    RC_TEST( rc );
    RC_TEST( render_layers.push_back( layer3 ) );

    RED::RenderLayer layer4( RED::RenderLayer::LT_NORMAL, imageNormal, viewpoint, rc );
    RC_TEST( rc );
    RC_TEST( render_layers.push_back( layer4 ) );

    // Rendering:
    bool complete = false;
    while( !complete )
    {
        window->FrameTracingImageLayers( complete, render_layers );
    }