GDC session summary: Battlefield 3 Radiosity

Add comment!

March 7th, 2011

I attended some great talks at the Game Developer Conference, so I'd like to summarize some of my favorites for you in blog post form. The first one was given by a senior artist at DICE, about:

Radiosity in Battlefield 3

If you're not familiar with radiosity, it refers to bounced lighting -- for example, if you shine a light onto a bright red wall, it will reflect red light back onto the rest of the room. After working on Mirror's Edge, the DICE team appreciated the power of radiosity, but disliked how long it took to compute: the lighting for each ME level could take more than 24 hours to bake (using Autodesk's "Beast" lighting engine). With such long baking times, the lighting artists spent too much time waiting and not enough time iterating through different lighting setups.

Left shows direct lighting only, right shows direct and indirect combined

To avoid this problem for Battlefield 3, DICE partnered with Enlighten (a real-time radiosity pioneer) to provide a lightning-fast workflow for the lighting artists. The PC version of the game will use this technology in the game itself to change the indirect lighting in response to destroyed walls, but the XBOX and PS3 ports will just use it to bake static indirect lighting. On both platforms, dynamic objects will not contribute to the indirect lighting, but only receive it by interpolating between regularly-spaced light probes (using spherical harmonics).

Spherical harmonic light probes

Enlighten performs radiosity in real-time using a number of simplifications. First, it uses an extremely low-detail approximation for each surface; for example a 5000-triangle building may be reduced to a simple cube. Second, it uses very low-resolution lightmaps. Indirect lighting often has large, smooth gradients, so these coarse lightmaps look acceptable in practice. Finally, each pixel of these lightmaps has a precomputed list of sample points and contribution weights, so no ray-casting or other expensive math needs to be done in real-time.

Left shows the low-detail approximation, and right shows the interpolated results

After precalculating this information, Enlighten can be used to calculate radiosity by providing it with the direct lighting information for the sample points. It then applies the weighted accumulation for each lightmap pixel to calculate the first bounce of the indirect light. It then provides the output from the first pass as input to the second pass, and so on (usually four passes in total).

Direct lighting and the direct light sample points

Even with all these simplifications, Enlighten is not fast enough to do per-frame radiosity for a whole level. For example, if you move the sun in the editor, it can take a few seconds for all of the lighting to update. This problem also makes it impractical for instantaneous light effects in games, like muzzle flashes or explosions. However, reducing lighting bake time from 24 hours to 3 seconds is quite an achievement!

The basic idea behind the algorithm was a lot simpler and more intuitive than I expected, given the apparent complexity of the problem. There are a lot of sub-problems that are tricky in their own right (such as mapping the low-detail texture map to the detail mesh, efficiently accumulating the lightmap passes, and pre-calculating the sample point weights) but they are more technical than theoretical.

We won't have time to implement real-time radiosity in Overgrowth, but it would be fun to try it for a future project, and there may be some lessons I can take away from their implementation to speed up our ambient occlusion bake times.

Images adapted from their Siggraph presentation slides and video.