Using Photon Mapping in Games

[ LiB ]

Using Photon Mapping in Games

The next logical step to using photon mapping in a practical application is to either place the algorithm into a 3D CAD program or into a video game. With the recent development of the X-Box and Play Station 2, it would be wise for any game development company to add photon mapping to their repertoire . The addition of the algorithm to a game is advantageous due to the heightened realism in lighting effects. Ideally, photon mapping should be done in hardware with the new hardware rasterizers. This adds a tremendous advantage to games with the new color bleeding, indirect illumination , and caustic effects.

So how do you add mapping to a game using software programming? Well, it can be done in two ways. The two photon-mapping methods for lighting in a game are known as pre- processed and real-time. The following sections briefly cover these two techniques.

NOTE

NOTE

Photon mapping has been used in real commercial games such as Ghostmaster by Empire Interactive.

Pre-Processed Photon Mapping

The concept of pre-processing light and storing it as light maps isn't new. For many years , games like Quake and Unreal have used pre-processed light maps for lighting in games. Currently, it is almost impossible to add real-time light-ing to a software application on a PC because PCs are still considered slow when it comes to lighting. With the recent development of hardware rasterizers, lighting effects are possible. Today, there are incredible games like Halo 2 , Spider-man , and Grand Theft AutoVice City that have wonderful hardware light-ing. The new hardware boards available today by n VIDIA can render 60-150 million triangles per second with 128MB of video RAM at 60+ frames per second.

Adding light maps to textures in a game isn't a costly process anymore with the high amount of video RAM available. Empire Interactive's Ghostmaster uses photon mapping for lighting in the game. To add photon mapping to a game using the pre-processed method, you extract the rendered lighting from the scene. The lighting information that is extracted represents the intensity shade for each object in the scene. The downside to using this technique is a few lighting effects, such as color bleeding and mirror reflections, are omitted in the process. Extracting the lighting information from the scene in a practical application is very simpleall you need to do is render the photon map and then extract the lighting information as a textured light map for each object in the scene.

This brings up another problem when extracting light maps from the scenerecall that curved surfaces like spheres are a pain in the neck to extract and create light maps from. Figure 14.12 shows a general idea for how to light an object.

Figure 14.12. Light mapping.

graphic/14fig12.gif


Real-Time Photon Mapping

The concept of making photon mapping real-time involves looking at the algorithm and trying to determine how you can increase speed by changing the way you render the photon map. Currently, you pool all photons together in one build. But if you were to use photon mapping in a real-time game, you must change the way you build and render the photon map. For example, a typical build of a global photon map is one million photons. If you were to do this in a game, you would only shoot a few hundred photons per frame based on your current location in the world. Using fewer photons per frame yields a poor estimation of the indirect illumination effects. If the camera is located at one position and changes orientation, the same pre-built photon map in the last frame can be used. This means you can build a cache of photon maps for the last few frames to increase performance in the application. As soon as old photons become stale, you replace them with the newly built photon map.

You add such a real-time process to your game by using vertex shading. You can use DirectX, OpenGL, or the XBox XDK. The photon contribution is applied to each vertex of a triangle in the frustum of the camera. When a triangle is rasterized in hardware, the radiance estimate is applied to each vertex. Figure 14.13 shows an example. This would retain the color bleeding effects that were lost by using the pre-processed method.

Figure 14.13. The pho- ton contribution at each vertex of a triangle.

graphic/14fig13.gif


The general process to implement this technique is as follows :

  1. Build the photon map in each frame by shooting a selective set of photons.

  2. Render each triangle using the radiance estimate for each vertex.

  3. Keep the scattering and rendering passes to a minimum where the frame rate is smooth.

NOTE

NOTE

Real-time lighting using photon mapping seems more easily emulat ed than radiosity because it's a relatively simple algorithm.

[ LiB ]


Focus On Photon Mapping
Focus On Photon Mapping (Premier Press Game Development)
ISBN: 1592000088
EAN: 2147483647
Year: 2005
Pages: 128
Authors: Marlon John

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net