Sign in with
Sign up | Sign in

The Basic Concepts

When Will Ray Tracing Replace Rasterization?
By

The basic idea of ray tracing is extremely simple: for each pixel of the display, the rendering engine casts a ray that propagates in a straight line until it intersects an element of the scene being rendered. This initial intersection is used to determine the color of the pixel as a function of the intersected element's surface.

But this alone is not enough to achieve realistic rendering. For that, the lighting of the pixel also needs to be determined, which is done by shooting secondary rays (as opposed to the primary rays that determine the visibility of the different objects making up the scene). To calculate a scene's lighting effects, secondary rays are emitted toward the different light sources. If these rays are blocked by an object, then the object in question is in a shadow that the light source under consideration casts. Otherwise, that light source would affect its lighting instead. The sum of all the secondary rays that have reached a light source determines the quantity of light falling on our scene element.

But that's still not the whole picture. In order to achieve even more realistic rendering, the indices of reflection and refraction of the material have to be taken into consideration. In other words, the amount of light reflected at the point of impact with the primary ray and the amount of light that passes through the material have to be accounted for. Here again, rays are emitted to determine the final color of the pixel.

In summary, there are several types of rays. Primary rays are used to determine visibility and are like the Z-buffer used in rasterization. Then, there are secondary rays, which consist of:

  • shadow rays
  • reflection rays
  • refraction rays

The classic ray tracing algorithmThe classic ray tracing algorithm

This ray tracing algorithm is the result of the work of Turner Whitted, the researcher who invented it 30 years ago. Until then, the ray tracers of the period worked only with primary rays. Thus, the improvements made by Whitted were a giant step toward realism in scene rendering.

If you have some physics courses under your belt, you will have noticed that the way ray tracing operates is exactly the inverse of what happens in the real world. Unlike the belief widely held in the Middle Ages, our eyes don't send out rays, but instead they receive the rays of light from light sources that have been reflected off the various objects by which we're surrounded. That's how the first ray tracing algorithm worked, in fact.

But the main disadvantage of the technique was that it was extremely computationally-expensive. For each light source, thousands of rays had to be cast, many of which had no influence on the scene being generated (because they didn't intersect the image plane). Recently-developed ray tracing algorithms are an optimization of the basic algorithm and are referred to as backwards ray tracing, since the rays propagate in the opposite direction from what happens in reality.

The original algorithm, which made too many unnecessary calculationsThe original algorithm, which made too many unnecessary calculations

React To This Article