Editorial Policy
   Contact Information
   Advertising Info
   Publicist Info
   Privacy Statement
   Contact 3Dgate

TUTORIAL • September 25, 2000

Realistic Lighting: Global Illumination and Final Gathering

A Softimage|XSI tutorial

by Anthony Rossano

First-time animators often overlook the role of lighting in computer graphics. In larger production houses there might be a number of people who work everyday as virtual lighting designers, people with real-life lighting experience and the theoretical background required to put that knowledge to good use in CG. These people often employ sophisticated cheats to wring effective lighting out of the limited lighting models found in most 3D rendering engines, cheats like hanging lots and lots of small dim lights that cast only diffuse light, or pre-rendering lighting effects into texture maps. To understand why this has been necessary in the past, and what we're going to do about it in the future, we need to understand how traditional raytracing differs from real physical lighting.

To simplify the discussion, we are going to assume that light is a particle, called a photon, although light also has some qualities that make it more like a 3D wave propagating through space. The software we'll use to illuminate the discussion is Softimage|XSI.

Real lighting versus CG

In real life we work hard to diffuse our light, so that it is not emitted all from one point source in the same direction. That's why we use fluorescent tubes with a lot of surface area, it's why we use frosted lightbulbs, it's why we use lampshades. In CG, however, the light comes most often from an infinitely small point source. This creates harsh lighting conditions, strong sharp shadows, and less dimensional looking images. Previous methods of solving this problem in CG involved using a lot of lights, or using area lights that require many more samples to render and thus increase rendering time.

Bouncing light energy.

In a real lighting situation, a light source (like the overhead light in the room pictured) constantly shoots particles of light from the surface of the bulb out in all directions into the surrounding room. These particles (photons) fly out at the speed of light until they contact another object. If the object is opaque, it will actually absorb the photon energy, and radiate some of it back out into the room. The new photon will cruise straight out until it strikes another surface, where again it will be absorbed, and again some of it will be emitted back off of the object into the room.

At each stop, the photon loses energy and changes wavelength. Losing energy causes the bounced light to become dimmer after each bounce, until it eventually becomes imperceptible.

We perceive how much light is emitted back from a surface as the value of the surface color. When the value is high, like a harsh, pure white wall in a hospital, much of the light that hits the surface is re-emitted. When the value is low (dark), less light makes it out of the surface. If a material is completely flat black, it has a value of 0, so none of the light that strikes it comes back and we cannot see it at all—it's a black hole. In addition to losing energy due to the value of the material it bounces off, we also say that light falls off (becomes dimmer) as it passed through space. What's really happening isn't that the photon is losing energy, but that as it travels out into a larger volume, the density of photons in a given area falls, so the total energy in the area falls. In computer graphics you have the advantage of controlling this light falloff by varying the Light Exponent. Normal light falls off as the square of the distance (an exponent of two), but this often makes it hard to cast enough light to illuminate your scenes. A linear falloff (an exponent of one) makes it easier to get lighting throughout your scene, but it doesn't look as natural. The best case lies in the middle somewhere.

Color bleed

We perceive the wavelength of the light as color, or more precisely, as hue, ranging from long waves in the red part of the spectrum to blue and violet in the shorter range of the visible spectrum. So, as the light bounces and changes wavelength, it changes hue as well, picking up the hue of the surface it radiated out from. For example, if you place a strip of red oriental carpet next to a white wall in the bright sunshine, the wall near the rug will look slightly red. Simulating this effect is often called Radiosity. In Softimage|XSI it is called Global Illumination, and Final Gathering.

Light travels forward, raytracers trace backwards.

Both of these lighting effects (bouncing light energy and color bleed) add to the subtle beauty of natural lighting. Both require also that the light source pour out thousands of photons into the environment and bounce them around until some of the photons happen to find their way to our eyes or to a camera lens. Unfortunately, raytracing engines don't work that way. A raytracer follows the light backwards, from the virtual camera back through the lens, out into the environment, to an object and then stops, checking only the light color and energy directly cast by lights on the object without intermediate bounces. Since it follows the rays backwards, a general raytracer simply can't generate lighting effects that rely on the physics of bounced light.

Solving lighting problems with Softimage|XSI

XSI 1.0 has rendering features to solve the above problems and simulate natural looking lighting effects. (You can also use these techniques to create fantastic and unreal lighting conditions.) The general idea is to cast light forward, from the light source into the environment, then bounce it around a bit, storing the results in something called a Photon Map, and then rendering the scene in the usual way, casting rays backwards from the virtual camera into the scene, until the ray strikes an object. Then the object color is determined in the normal way, and the photon map is consulted as well, to add in the effect of the bounced light. This method is called Global Illumination in XSI.

Global Illumination can be augmented ever further by the use of another XSI rendering effect called Final Gathering. Final Gathering works by casting many rays into your scene from the point on each object where a ray lands. Refer to the diagram for a visual idea of what this means. In general, these effects all add considerable rendering time, so be aware that the increased quality you get will require patience and free time. Let's examine each of the two effects separately before combining them.

Setting up Global Illumination

This room has no Global Illumination yet; just normal raytraced effects.

The workflow for Global Illumination is simple. You'll spend the majority of your time fine tuning the parameters to examine differing results made possible by changes in the Global Illumination properties. It's smart to use settings that will render fast while you are tuning up the effect, so you can make many iterations and test renders before settling on the result you want.

There are four requirements for global illumination to work in your scene:

  1. You must have a light set up to cast photons.
  2. You must have at least one object set to transmit the photons that hit it from the light, bouncing them into the rest of the scene.
  3. You must have at least one object set to receive the photons that hit it after bouncing around in the scene.
  4. You must turn on Global Illumination in the Render/Region/Options dialog.

Step 1: Choose your light, probably either a point or spot light, and in the Property Editor for the light go to the Photon tab and click the Global Illumination toggle. Directly below this toggle are two additional sets of sliders, for Photon Energy and Number of Emitted Photons. The Energy determines how bright the effect will be. Increasing this value does not affect render time. It's a good idea to set this very high—like 50,000—while testing the effect. Be aware that the light fall off will change the energy level of the photons. You should make sure that Light Falloff is toggled off while setting up, then turn it on later. Set it to Use Light Exponent, and carefully turn up the intensity while adjusting the Light Exponent (in the general tab of the Light Property Editor) between 1 and 2. Setting the light exponent to one will make your global illumination more obvious, setting the light exponent closer to 2 will localize the effect and make it more natural, though harder to see.

The slider below that, Number of Emitted Photons, does have a great impact on render time. It's a good idea to set it very low, like 1000, while tuning the effect, and then increase the number for the final render.

Step 2: Set up the Global Illumination transmitters. When a photon from the light hits an object and you want that object to re-emit the photon, the object needs to be a Global Illumination transmitter. For instance, the carpet is a Global Illumination transmitter, because photons from the light bounce off the rug, collecting the hue and value from the rug, before splashing that color information onto the walls.

Select the object that will transmit the photons, and call up the Visibility Property Editor. Toggle on the Transmitters check box in the Global Illumination editor section.

If the object is transparent, the photons will go through the object and will be deflected by the index of refraction, bent through the object to emerge in a different location. An object can be both a transmitter and a receiver. When a translucent and refractive object is both, internal glowing patterns can be created as the photons bounce around inside the object, adding energy to the surface.

Step 3. Set up the Global Illumination receivers. The receiving object collects photons onto its surface to create the photon map. Without at least one object as a receiver nothing will happen. Optimally, all the large flat surfaces (walls, floors, tables, and ceilings) should be receivers. Select the object and open the Visibility Property Editor, and toggle on Global Illumination Receiver check box.

Now the room has photons spilling from the two light sources: the table lamp and the overhead light.

Step 4. Turn it on! Open the Render Region Options Property Editor from the left side menu stack in the Render module. Under the Photon Tab, toggle on the Global Illumination check box to activate the effect. Leave the Accuracy and Radius sliders at the default for now. Draw a render region and look for the results. If you watch the lower right corner, you will see that a progress bar pops up. The first thing to happen is the creation of the photon map. If you get tired of waiting for the render region to show something, you're probably casting too many photons from your light. You can abort the render by clicking the small red X to the left of the progress bar, and cast fewer photons in the Light Property Editor.

Continued on page 2. >>