Download this article in .PDF format
This file type includes high-resolution graphics and schematics when applicable.
Like ray casting, ray tracing “determines the visibility of surfaces by tracing imaginary rays of light from viewer’s eye to the object in the scene.”1
Ray casting is faster than ray tracing.
Ray casting is faster because its world is limited by one or more geometric constraints (simple geometric shapes); a ray-tracing world can be almost any shape. Ray casting was developed in the early 1980s and was successful exploited by John Carmack in his ground-breaking 3D shooter, Wolfenstein 3D (iD Software),2 in 1992 (Fig. 1). Ray casting is a technique that transforms a limited form of data (a very simplified map or floorplan) into a 3D projection by tracing rays from the view point into the viewing volume.
1. This is the now iconic Wolfenstein 3D screenshot (Courtesy of Wikipedia)
The term ray casting was first used in computer graphics in a 1982 paper by Scott Roth to describe a method for rendering constructive, solid geometry models.3
Ray casting is considered the most basic of computer-graphics rendering algorithms and uses the geometric algorithm of ray tracing. The first ray-casting algorithm used for rendering was presented by Arthur Appel in 1968.
However, ray casting is much faster than ray tracing. The speed and simplicity of ray casting comes from computing the color of the light without recursively tracing additional rays that sample the radiance incident on the point that the ray hit. That eliminates accurately rendering reflections, refractions, or the natural falloff of shadows; however, all of these elements can be faked to a degree, by use of texture maps or other methods creatively, sometimes referred to as hand baking. The high speed of calculation made ray casting a well-used rendering tool in early real-time 3D video games.
Ray-tracing-based rendering algorithms operate in image order (from the screen or viewer to the light source) to render three-dimensional scenes to two-dimensional images. Geometric rays are traced from the eye of the observer to sample the light (radiance) traveling toward the observer from the ray direction (Fig. 2).
2. This ray-traced image of glasses shows the perfect reflections and refractions, as well as shadows. (Courtesy of Gilles Tran)
Ray tracing can generate a very high degree of visual realism, higher than that of typical scanline rendering methods. However, it uses a lot more compute cycles. Therefore, ray tracing has been relegated to applications in which the image can be rendered slowly ahead of time, and in those that require highly accurate reflections and shadows.
Ray tracing can be used for still images and film and television visual effects, but not yet in real-time applications like video games, where speed is critical. Ray tracing is capable of simulating a wide variety of optical effects, such as reflection and refraction, scattering, and dispersion phenomena (e.g., chromatic aberration).
3. "RayCharles1983" by Rob Bogaerts. (Courtesy of Wikipedia)
What does that have to do with Ray Charles (Fig. 3)? Well nothing really. I just like the iteration of Ray, and the notion that he could “see” beautiful images of sound and music that the rest of us could only imagine.
If ray casting takes 10 cycles (to render any given image), ray tracing would take 100 to 1000 cycles. And a voxel rendering (done honestly) would take 10,000 or more. Folks have employed various tricks to make voxel rendering look as if it was rendering faster. But like ray casting, they were tricks that brought artifacts and inaccuracy with them. And they usually weren’t even very pretty.
4. A field of voxel-rendered oranges was rendered and shown in real time (25 to 40 fps at 768 lines) in 2009. (Courtesy of Unlimited Detail)
The easiest way to think of a voxel is as a 3D pixel—a cube (Fig. 4). As a cube, it has six times as many surfaces to process than a simple pixel. Now, it’s true that all six sides can’t be seen, but at least two, if not three, are viewable.
Voxels can be used to render clouds of smoke, ocean waves, and other ultra-dynamic and usually non-predictive flows (Fig. 5). They’re also used for medical imaging. Voxels are used to build the digital slices that make up tomograms and MRIs (magnetic resonance images).
5. Flames and smoke were created using voxels. (Courtesy of Nvidia)
In modern computer graphics, all three techniques can be utilized, and often are, especially in cinema. The computer-graphics tool box is full of clever and useful tools. And like any good mechanic or carpenter, one doesn’t try and use one tool for all problems. So the difference between ray casting, ray tracing, and voxels is speed versus accuracy. And just as Ray Charles would mess up his music if he tried to play it at the wrong tempo, a computer image will be messed up if the wrong tool is used in the name of speed. One has to find the right tempo for a given image.