Revisiting Reflection and Refraction

[ LiB ]

Revisiting Reflection and Refraction

We haven't really talked about reflecting and transmitting light in ray tracing. After the ray hits a reflective material some of the energy is emitted back into space. As the energy travels it can then bounce (reflect) or refract (transmit) onto nearby surfaces. For this reason the light reflection/transmitting algorithm must be capable of handling multiple bounces of rays moving from object to object. For refraction we must consider the light partially passing through the object. As we said in Chapter 3, refraction occurs on transparent objects. This means that the opacity of the object must be less than 1.0. If the object is specularly reflective to some degree a new ray is traced from the point of intersection towards the reflection. See Figure 9.11.

Figure 9.11. An example of (mirror) reflection on a sphere.

graphic/09fig11.gif


The new ray can then bounce from object to object. The number of times a ray interacts with an object must be limited. Now if you think about it the multiple bounces of a ray from the image plane can be seen as a tree of light paths.

Let's take a look at the steps required to simulate reflection and refraction. We are going to alter the Tray_Ray_In_Scene() method to accommodate the new functionality required to reflect and refract rays. If you're a bit hesitant about the new changes in the method, don't worry because we're not going to conduct any major changes to the method.

To trace the ray in the scene, you follow these steps:

  1. Find the closest intersection with the scene.

  2. Compute the intersection point and the normal.

  3. Color = Shade Point( point, normal )

  4. Reflected Shade = Spawn Reflected Ray

  5. Color += Add Reflected Shade

  6. Refracted Shade = Spawn Refracted Ray

  7. Color += Add Refracted Shade

  8. Return the color.

As you can see, the changes are minimal with only a few more steps required for reflection and refraction. Let's take a look at a program designed to perform reflection and refraction in the next section.

[ 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