Ray Tracing

Ray tracing is a technique used for generating highly realistic images. The ray tracing technique attempts to model the physical properties of light and can correctly handle such visual artifacts as shadows, reflection, and refraction.

Ray tracing reverses the traditional rendering process. Instead of projecting each vertex of the geometric model onto the picture plane and then scan converting to determine the appropriate pixel values, ray tracing starts with a particular pixel and determines what geometry will be mapped to it.

The picture plane (the near clipping plane) can be subdivided into discrete regions each of which corresponds to a single pixel in the frame buffer. A ray is cast from the view point (or center of projection) through the center of one of these subregions and into the geometric model. This ray may have many intersections with various pieces of the model.

If the model consists of an opaque, non-reflective material, then the RGB value of the corresponding pixel depends only on the local color of the object (at the point of the intersection closest to the view point) and the lighting model.

In the traditional rendering model, the lighting effects are local; each polygon is rendered in isolation from surrounding geometric model (apart from hidden surface calculations). In ray tracing, we want to reproduce the effects of a global lighting model, with visual interaction between separate parts of the model, such as occluded light (shadows), reflections, and refractions.

Because each intersection point may generate up to three additional rays, we can see that ray tracing lends itself to a recursive program structure.

  color RayTrace(Vector point, Vector direction, int depth)
  {
    if (depth > maxDepth)
      return black;

    Find closest intersection;

    if (no intersections)
      return black;

    reflect-color = RayTrace(intersection, reflect-direction, depth+1);
    refract-color = RayTrace(intersection, refract-direction, depth+1);

    return local-color + reflect-color + refract-color;
  }

To ray trace a complex object at a high pixel resolution there are potentially millions of intersections to calculate. Thus, it is of paramount importance that the program be as efficient as possible.

where I is the incident ray, R is the reflected ray, T is the transmitted ray, and S is the shadow ray.

This ray tree grows at a maximum rate of 2^n + 2^(n-1), for the depth n. Not only do we want to have an efficient method for calculating intersections, but we also need to try to calculate the fewest number of intersections as possible, since each intersection may lead to additional rays.


Back to the 13.016 overview...