Adding a background

The RED::IViewpointRenderList interface offer all the services to setup some background before rendering all data from all scenes it has to display. First there can be two types of backgrounds managed by the VRL:

Rendering flow of the three buffer clearance points in a VRL

The rendering of the background occurs at the first clear time, before any rendering operation in the VRL.

Color based background

By default, the background of a VRL is black. The color of the background is specified using RED::IViewpointRenderList::SetClearColor. Associated to this, the background depth is specified by RED::IViewpointRenderList::SetClearDepth. The default clear depth is 1.0, which is standard for a framebuffer.

The clear depth is reused twice after the initial clear, before the scene camera list is rendered and finally before the front camera list is rendered. The depth buffer is not cleared again if there's no viewpoint to draw after the clear operation. For instance, we don't clear after the RED::VST_SCENE list of cameras if we have no cameras in the RED::VST_FRONT list.

Clear color is clamped to the buffer format storage limits. For instance, in a HDR format VRL, the clear color can be any positive or negative floating point value. In a RGBA 8 bits color buffer, each clear color component will be clamped to [ 0, 255 ].

Clear depth ranges between [ 0.0f, 1.0f ].

Image based background

Background images can be specified using RED::IViewpointRenderList::SetBackgroundImages. REDsdk can simultaneously manage two background images:

If there's no 2D image, the cube image is also seen for direct rays.

Background images hit by different rays

Mixed 2D / 3D backgrounds are often used in the architectural market for 'on site' insertion of virtual 3D models into 2D photographs.

Practical background setup

Please refer to this tutorial: Background setup: A CAD style example for an example of CAD style gradient background setup.