All About Lighting

by Ga'ash Soffer on December 26, 1998 7:57 PM EST

Radiosity, as close as it gets...

Ok, we know Phong shading is cool, Gouraud shading is fast, etc. But how do games like Quake2 and Unreal create such realistic environments? Well, they use a lighting method called radiosity. Unlike Phong shading, Angle interpolation, and Gouraud shading, Radiosity is NOT a real-time technique, and probably won't be for a long time. It takes hours to compute Radiosity lighting for moderately sized scenes. Ok, so we know it's slow as hell, but what exactly is radiosity lighting?

What it is...

Radiosity lighting not only takes into consideration the "obvious" light sources (i.e. a lamp), but also treats every reflective (ambiguous term, almost any surface can be said to reflect some light) surface (polygons) as a light source. (Since every object either reflects some light or gives off some light) Now, if we were to do calculations per polygon, that would be very ugly, since each polygon would be assigned one color. For this reason, in order to calculate radiosity lightmaps (yep, lightmaps are calculated and then blended in with the texture), we must divide the polygons into 'patches' (small pieces of polygons...sort of). After the polygon is divided into patches, each patch is lit by every light source and every other patch. Obviously, this approach is very slow, because a typical scene can have tens of thousands of patches (even more!). We have to check each patch with every other patch, which means, for 10,000 patch scene, 10,000*10,000 checks (O(n^2), for those of you who care :). Even though radiosity takes forever to calculate, and imposes the restriction of static environments, the benefits are tremendous. Take a look at the following screen shot, showing what radiosity lighting alone can do to enhance the realism of a scene.

radiosity.jpg (19066 bytes)

taken from Thomas A. Funkhouser's
Database and Display Algorithms for Interactive Visualization of Architectural Models.
PhD Thesis, Computer Science Division, UC Berkeley, September, 1993. Click here for 167 page PS file

Which lighting method is the best?

As if you already didn't know what I was going to say... there is no "best" lighting method. Radiosity is by far the most realistic, but it imposes the restriction of a static environment, with static lights. This is acceptable for now, but soon, gamers will be demanding dynamic environments.

Phong and Angle Interpolation and Dynamic Environments

The remaining three lighting methods I talked about are fast enough for real time rendering of an arbitrary environment. Actually, that depends on the number of lights. For angle interpolation and Phong shading, using the texture blending method, 1 texture must be blended for every light source (which affects the polygon). Now, if we have 10 light sources, anything about 640x480 will slow to a crawl on current accelerators. 20 light sources on the same polygon will bring even the all mighty Voodoo2 SLI to its knees. The problem with multiple lights when using Angle interpolation and Phong shading is that complexity increases on the pixel level. Since there is no way to do some "average normal" calculation to find out 1 normal at each vertex which will take into account all the light sources shining on the polygon, we must deal with each light separately. (There might be some ugly method of finding an "almighty" angle (talking about angle interpolation) which will take into account all the light sources, but I doubt it.)

So what's left? (Gouraud)

Unlike Phong and Angle interpolation, It is very easy to calculate an "almighty" intensity which will consider all the slight sources on the polygon. This reduces the problem with multiple lights from the pixel level to the polygon level. The only task now is to calculate the intensities at each vertex based on all the lights shining on the polygon. Unfortunately, this isn't very fast either, but currently, Gouraud shading is the fastest most feasible dynamic lighting method for areas with many light sources.

Mixing it all together

Now, we don't want to start using Gouraud shading all over again just because we can't do dynamic lighting with Radiosity, so what do we do? We can mix Gouraud shading with precalculated lightmaps to do dynamic lighting quite nicely. Of course, this won't be entirely accurate (the radiosity lightmap should change if a light is moved), but it will look much better than Gouraud shading alone, especially in the areas where there is little dynamic lighting going on. Judging from the flash lights in games like Half life, Blood2, and Unreal, I am speculating that this is the lighting approach they use.


Ok, that's all about lighting for tonight. Now you probably understand the basics behind some of the "hyping" lighting terminology used by game developers to pimp their new games.

The Highlight

Log in

Don't have an account? Sign up now