Raytracer
Aaron Etsokin, Chris Mueller, Justin Von Stroh
Fall, 2004
This project encompassed our brief excursion into the realm of raytracing. Our goal was to develop a basic three-dimensional world model that could be rendered as a two-dimensional image on the screen.
| How raytracing works: The blue square represents the camera's viewing plane. The brown triangle is an object in the scene, illuminated by the yellow light. Rays (shown in purple) from the camera are shot into the scene, and if they hit an object, the corresponding pixel on the camera's plane is highlighted. |
Raytracing is a standard technique for generating 2d images of 3d worlds. One popular raytracing program is POV-RAY. The basic idea of a raytracer is set up a "camera" that is looking at a 3d scene, which contains objects (like cubes or spheres) and lightsources. Then the program shoots imaginary light "rays" outward from a lightsource and to highlight those pixels in the camera's viewing plane that are hit by those rays. If light rays bounce off of objects in the scene, they pick up colors associated with those objects. More complex raytracers implement special lighting features and surface properties, such as refectivity or specularity.
In practice, the raytracer we developed does not work quite in this manner. Instead of shooting thousands of rays from the lightsources in our scene, we instead reverse the process, and shoot rays from the camera plane out into the scene, and then we record which rays encounter objects. When a ray hits an object at poit p, we then try drawing a ray from point p to each of the lightsources in the scene. If this new ray is able to touch the lightsource without any other objects getting in the way, then we highlight p with the light from that lightsource. Otherwise, p is in the shadow of another object, so we do not highlight it. This method of shooting rays and checking for lightsources includes the assumption that the surfaces of objects in the scene are very matte, and their illumination is independent of the angle at which a light hits them.
Our raytracer includes only the ability to draw triangles and point lightsources. We implement triangles as structs containing three points (x,y,z), a color, and some variables to control reflectivity properties. Lightsources are structs containing a coordinate, color, and intensity.
The scene shown here demonstrates all the features of our raytracer. The purple triangle in the middle is actually a triangle that exists in front of the viewing plane, and it is only visible because it is being reflected off of the other triangles. There is a lightsource behind the green triangle on the right, and the back of that triangle can be seen reflected in the red triangle in the back. The gradients of colors are produced by light interacting from several lightsources.
| CG Index | Square Fountain | Van Gogh | Raytracer | Computer Vision |