Setting Up Rendering Layers

Render layers are available to software rendering. RED::IWindow::FrameTracingImageLayers must be used in order to retrieve render layers after the processing of an image. RED::IWindow::FrameTracingImage can also be used, but it retrieves only the color and depth layers of the image.

RED::RenderLayer objects are used that way:

RED_RC rc;
RED::Object* imageColor, *imageMaterialID, *imageNormal, *imageReflect;

RC_TEST( iresmgr->CreateImage2D( (RED::Object*&)imageColor, iresmgr->GetState() ) );
RC_TEST( iresmgr->CreateImage2D( (RED::Object*&)imageMaterialID, iresmgr->GetState() ) );
RC_TEST( iresmgr->CreateImage2D( (RED::Object*&)imageNormal, iresmgr->GetState() ) );
RC_TEST( iresmgr->CreateImage2D( (RED::Object*&)imageReflect, iresmgr->GetState() ) );

// Specify render layers for the camera 'viewpoint':
RED::RenderLayer layer1( RED::RenderLayer::LT_COLOR, imageColor, viewpoint, rc );
RC_TEST( rc );
RED::RenderLayer layer2( RED::RenderLayer::LT_MATERIAL_ID, imageMaterialID, viewpoint, rc );
RC_TEST( rc );
RED::RenderLayer layer3( RED::RenderLayer::LT_NORMAL, imageNormal, viewpoint, rc );
RC_TEST( rc );
RED::RenderLayer layer4( RED::RenderLayer::LT_REFLECTION, imageReflect, viewpoint, rc );
RC_TEST( rc );

RED::Vector< RED::RenderLayer > render_layers;
RC_TEST( render_layers.push_back( layer1 ) );
RC_TEST( render_layers.push_back( layer2 ) );
RC_TEST( render_layers.push_back( layer3 ) );
RC_TEST( render_layers.push_back( layer4 ) );

RC_TEST( iresmgr->EndState() );

bool complete = false;
while( complete == false )
    RC_TEST( iwindow->FrameTracingImageLayers( complete, render_layers ) )

iresmgr->BeginState();

Nothing fancy in there: images are created by the application, and sent to the rendering method. Once the rendering is finished, all the images can be accessed and their pixel arrays will contain the selected information. Please note that some rendering layers have images available in their local storage (CPU only), and some others have both CPU and GPU contents (these are the color and depth layers).

Please refer to the RED::RenderLayer class documentation for the traduction of the contents of a rendering layer.

The life of the render layer images is not related to the RED::RenderLayer objects that are generally created on the fly in the calling method. After the end of the rendering, a render layer image will not be modified by another rendering, unless its used again as a layer image.