The Solution

[ LiB ]

The Solution

The first part of the solution is to solve the meshing problem that radiosity poses. You want to store the illuminative information as a primitive in a global list that can be archived and searched for later. This list would be used anytime in the application to retrieve incoming lighting information relative to each point on a surface. You need a primitive that is much smaller than a patch and that requires less memory consumption. It needs to be resilient and nominal in size; it must have the capability to handle any type of geometry.

The requirement is to simulate energy particles moving around in space. The simple solution is to use a very small structure similar to a 3D point. Points can determine position, which is one important element of lighting. You also need an intensity component that carries a fraction of the light source's power. But it doesn't stop here. Light waves travel in an arbitrary direction, so you need a direction component. Combining these three components yields the photon .

The Photon

The following code shows the photon structure that includes the three attributes of energy, direction, and position:

 typedef struct {    color3   tPower;    cVector3 tDirection;    cVector3 tPosition; } photon_t; 

Photons are compact and use a lot less memory than low-resolution patches, used in radiosity. The list of photons sitting across each surface in the scene is called the photon map . Using photons not only serves the needs for simple surfaces, but can also enable you to represent very irregular and complex geometry. Curved surfaces are a nightmare to compute in radiosity. Using simple photons creates a resilient representation because photons are very small and compact. You don't have to worry about the meshing constraints, as you do in radiosity. Ray tracing uses point calculations constantly and that's why it is very good at computing specular reflections, typically mirrors. You can use photons to calculate curved surfaces such as clouds, liquids, smoke, and many other irregular objects such as rocks, trees, and concrete.

In ray tracing, we traced rays moving from the eye into the scene that reflected a few objects. This movement the ray takes is known as the eye-to- object path . Similarly, the photon map is like a list of light paths taken from the light source to the surfaces and from the camera to the surfaces. These different path movements are recorded in a map. Begin by taking a look at Figure 10.1.

Figure 10.1. The photon map preserves the light paths taken from the light sources to objects as well as the path from the observer to objects.

graphic/10fig01.gif


The photon map in Figure 10.1 is simply a list of photons in a simple array. To visualize its purpose, think of a set of light bulbs positioned in a box of wood. See Figure 10.2 for an example.

Figure 10.2. These light bulbs illustrate the idea of photons contributing to the appearance of a surface in the scene.

graphic/10fig02.gif


As you know, each light bulb carries a different wattage. Light bulb one is 60 watts, light bulb two is 80 watts, and light bulb three is 100 watts. Light bulb three emits the highest amount of energy. Now if you place a translucent glass cover over the top of this wooden box, what would happen? The glass cover would transmit the light and the three bulbs will appear as one single surface emitting light where each light bulb may cause a hot spot on the surface of the cover. See Figure 10.3 for an example.

Figure 10.3. The glass cover simulates light leaving an area.The three light bulbs con tribute to the overall intensity where a few hot spots appear on the surface.The photons stored on the surface contribute to its intensity shading across the surface.

graphic/10fig03.gif


Now, if you're really cunning, you might realize that this simple example is analogous to how the photons are stored on the surfaces in the scene. The photons are used to shade the overall appearance of the surface. Each light bulb can be seen as a photon that contributes to the overall intensity of the surface. The lighting on the cover is brighter where the wattage is higher. Figure 10.4 shows what would happen if you added more light bulbs.

Figure 10.4. More lights in a box show the overall intensity of light with more detail and fewer hot spots on the glass cover.Similar to adding more photons to the surface,this tech nique helps to generate a better render of diverse lighting across the surface.

graphic/10fig04.gif


The primary idea is to separate the lighting information from the geometry in the scene so the lighting information can be used at anytime during the course of rendering. This lighting information is primarily a list of paths preserved in a list of paths taken from both the eye and the light sources. The photon map can be seen as a cache of light paths that contributes to the radiance of each point on a surface. The more photons there are at a surface, the more diverse the lighting across the surface.

The first step is to trace all photons from each light source into the scene, and then save the illuminative values at the surfaces in a global list for later retrieval. These illuminative values calculate the energy that is arriving at each surface or the incoming flux in the model.

The next logical step is to render the scene by tracing rays from the view plane to each surface into the scene. By calculating the average sum of a set of photons in a given area, you can find the radiance of each point on a surface. Don't worry if you're a bit lost here; more on this later. Each photon cannot determine the radiance of a point by itself because photons determine the irradiance and must be averaged with other photons to find the radiance.

If you were to trace the correct lighting on a surface, the photon map requires a higher density of photons to compute the radiance for a point. This means that if you want to shade an arbitrary surface in a scene, you must use a good number of photons to retrieve reasonable results. This is one minor problem with photon mapping. It is, however, the only way to alleviate the major problem of noise seen when rendering in ray tracing. The photon mapping radiance estimate for a point on a surface may not be the correct value because it suffers from some low-frequency noise. This isn't really a problem because the correct result can be found by using more photons. The result is a slow-changing value that is consistent in intensities. This is as opposed to ray tracing, which suffers from high-frequency estimates seen as noise.

The two passes of photon mapping are as follows :

  • Photon tracing: Build the photon map structure by tracing rays from the light sources to each surface in the scene. This pass captures the light as it arrives at surfaces in the scene.

  • Photon rendering: Render the scene using the information stored in the photon map to generate the final image. This pass basically captures the light as it leaves each surface in the scene.

[ 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