| Tracing light rays from a virtual camera into a 3D scene |
One of the graphical features that are easy to obtain using ray tracing is physically accurate and pixel-perfect shadows. As is apparent in the figure to the right, rendering a shadow is as simple as casting a ray from the surface of an object toward the center of a light source. If that ray intersects some object before it reaches the light source, the originating surface point is in shadow.
Simple!
Ever since I was introduced to GLSL, I wondered if it would be feasible to implement ray tracing on the GPU. The GPU, after all, is well-suited to geometrically-oriented computations. I decided to take the opportunity to find out by attempting to implement it as a final project for Chuck Hansen's course on Interactive Computer Graphics at the University of Utah. As a first pass, I decided to use ray tracing simply as a means of computing the shadows of an interactive OpenGL scene.
Read on for how I did it.