Ray Tracing Architecture

Pat Hanrahan

Practical Considerations in Writing a Ray Tracer

Process:For each pixel a primary ray will be generated and then tested against all objects in the scene.

Create Model

The first step is to create the model of the image. One should not hardcode objects into the program, but instead use an input file.

Generate primary rays and test for object-ray intersections

For each pixel we must generate a primary ray and test for intersection with all of the objects in the scene. If there is more than one ray-object intersection then we must choose the closest intersection (the smallest positive value of t).To ensure that there are no objects intersected in front of the image plane (this is called near plane clipping), we keep the distance of the primary ray to the screen and test all intersections against this distance. If the t value is less than this distance, then we ignore the object.

Generate the reflection and transmition ray

If there is an intersection then we must compute the shadow rays and the reflection rays.

Shadow ray

The shadow ray is a ray from the point of intersection to the light source. Its purpose is to determine if the intersection point is in the shadow of a particular light. There should be one shadow ray for each light source. The origin of the shadow ray is the intersection point and the direction vector is the normalized vector between the intersection point and the position of the light source. Note that this is the same as the light vector (L) that is used to compute the local illumination.

Local Illumination

Compute the Local Illumination at each point, carry it back to the next level of the ray tree so that the intensity I = Ilocal + Kr * R + Kt * T . Note that Kr can be taken as the same as Ks.
For each color (R, G, B) I is in the range 0.0 <= I <= 1.0. This must be converted to an integer value of 0 <= I <= 255. The result is then written to the output file.

Output File

The output file will consist of three intensity values (Red, Green, and Blue) for each pixel. For a system with a 24-bit framebuffer this file could be directly displayed. However, for a system with an 8-bit framebuffer, the 24-bit image must be converted to an 8 bit image, which can then be displayed.