This page describes the precomputed radiance transfer system I built for assignment 2 in CS294-13 (Advanced Rendering Techniques). This system allows real-time re-lighting of a scene with a fixed viewpoint. The technique relies on a set of precomputed images which are linearly combined to produce the final version.

Completed Features

* Basic relighting system using a small number of lights

* Real-time adjustments of weights to relight by varying light intensity and/or direction

* Environment mapping (supports 6x16x16 cube maps)

* Real-time rotation of environment maps

Basic Relighting System

For my basic relighting system, I started with a static scene and precomputed the image data for a small number of directional light sources using a raytracer from a previous assignment. I turned the global illumination off, but the scene was still rendered with correct shadows, reflections, and shading. These images are also antialiased. In this example, I used 41 lights uniformly distributed in the upper hemisphere of the scene. I rendered a scene consisting of a stack of balls on a gray ground plane. Here are a couple of the precomputed images:

Each image represents how the scene looks from one individual light. Because each image takes about a minute to render, it would be impossible to relight this scene in real-time using my basic ray-tracing code. By precomputing these images however, the computationally expensive rendering is completed offline and combining the images can be done in real-time.

The image-based relighting system loads these images into memory and then interactively renders the scene in real time by linearly combining a weighted average of the input images. In my system, the user can control the direction of illumination by simply dragging the mouse within the window. The user is also able to control how diffuse the lighting is using a keystroke. The images are weighted according to the distance between the light direction used to render the image and the light direction set by the user. The weights are adjusted according to the diffuseness of the lighting set by the user as well. If the user desires more diffuse lighting, then a wider set of nearby light sources are preferentially weighted.

In the above screenshot, the user has set a diffuse light to be slightly to the left and behind the viewer. This resulting image is a weighted average of the input images which were rendered from nearby light sources.

In this example above, the light has been set to be less diffuse. The input images which were generated from closer light directions were weighted more heavily than further light directions.

I can also change the colors/weights of the lights individually. In the above example, I've reset the colors and weights of the lights such that a slightly reddish light is coming from the lefthand side and a slightly greenish light is coming from the right.

Image-based Lighting System

I expanded the basic relighting system to handle more complex lighting with an environment map. This system is similar to the basic version except it is scaled up to handle enough light positions to support a simple environment map. I upgraded the system to handle simple cube environment maps with 16x16 faces. This requres precomputing the lighting for 6x16x16 = 1536 light directions. In order to reduce the data demands of such precomputations, I lowered the resolution of my output images to 256x256.

As with the previous system, I precomputed my original same for all 1536 light directions. Using this data, I can first simply relight the scene in real-time with different light directions and different light concentrations. Here are a couple examples of this in which I'm rotating the light direction around the scene (note the shadows are softer since I am linearly combining data from a larger set of input light directions):

Using this precomputed data, I can also load in an environment map and relight the scene according to the light values and colors in the map.

First I loaded a simple environment map consisting of 6 colored lights, one in each face of the cube map (above).

I can also rotate the environment map, and these two images (above) show the scene after the environment map has been rotated a little.

I can also load in environment maps acquired from natural lighting.

The above image is an example of my scene rendered using the Grace Cathedral environment map from Paul Debevec.

This example (above) was relight using the Eucalyptus Grove map from Paul Debevec.

This example (above) was relight using the Kitchen map from Paul Debevec.