Global illumination

Global illumination (GI) is a key asset in rendering photo-realistic images. It simulates how light interacts with the data in a natural way. REDsdk features a full GI support and this section will cover it in details.

GI includes direct lighting (light coming in straight line from known luminaries) as well as indirect lighting (light coming after at least one bounce on a diffuse surface). In REDsdk, GI refers to the indirect lighting component, the direct lighting component being always computed, even if GI is turned off.

See the differences between a scene without GI (on the left) and the same scene rendered with GI (on the right).

Enabling and setting GI up

As usual in REDsdk, enabling GI is only a matter of setting engine options:


Task: Enabling GI

To enable the usage of GI for a given RED window:

// win is a pointer to a RED window.
bool gi_enabled = true;

RED::IOptions* iopt = win->As< RED::IOptions >();
RC_TEST( iopt->SetOptionValue( RED::OPTIONS_RAY_GI, gi_enabled, iresmgr->GetState() ) );

There are some other options in REDsdk to control how the GI is processed, but default values have been tuned to give a good result in a reasonable amount of time for common scenes.

Method description

In REDsdk, GI is a two-step process. The first step computes a so-called GI estimator. It stores an approximation of the complete lighting in sparse positions in the scene. It's therefore a 3D structure. The number of entries in that structure (called GI samples) is quite high, but each entry only describes a very rough approximation of the light reaching it.

The GI estimator is computed by tracing rays from the camera into the scene and accumulating lighting information at ray intersections with the geometries. The visible result is a kind of path-traced image.

User feedback of RED computing the GI estimator.

During the second step, the engine computes a far better approximation to the GI, but in very few key positions in the scene. It uses information stored in the estimator to do so and produces another 3d structure to store the results: this is the GI cache.

The GI cache is computed across several passes. The first pass subdivides the screen into a number of sampling positions which depends on the The GI error. For each sampling position, a full GI calculation is performed by re-using the GI estimator computed previously. This is achieved by firing rays around the sampling position and, for each ray, using the GI estimator to approximate the light transported by that ray. Then, in each following pass, new sampling positions are added to refine the GI cache. The location of the new sampling positions is determined automatically from the GI samples of the previous passes by estimating the quality of the cache information.

User feedback of RED computing the GI cache. Small grey points are selected sampling positions white blocks in the background show the content of the GI estimator previously computed.

Finally, during the rendering step, information is collected from the GI cache and interpolated to reconstruct an estimate of the GI at the point being shaded. The interpolation introduced here helps in getting smooth, good-looking results from only a quite small amount of data. The drawback of interpolation methods is that they can miss details or over-smooth the lighting and cause light leaks.