Portfolio

Raytracer

One of my major assignments for CS184, Comptuer Graphics, was to build a raytracer capable of displaying images with spheres and polygons based on simple input files.

For each pixel, one or more “rays” is cast from an X,Y,Z “eye” coordinate. Using formulae for spheres and polygons, the application determines intersections between the rays and the objects in the scene. It also calculates intersections between light rays and the objects to calculate reflections and shadows.

Using the input files, the user could simply run ./raytracer [input_name] from the command prompt to generate the desired scene. I wrote the raytracer in C++ using OpenGL and implemented the following features:

  • Renders spheres and ellipsoids, performs transformations on objects
  • Renders polygons
  • Phong shading
  • Computes shadows
  • Computes reflections
  • Uses point and directional lights
  • Bounding box trees to speed up tracing
  • Write output to a file using FreeImage
  • Anti-aliasing through multiple samples per pixel

Below are some sample images I produced and the input files used to create them. Unfortunately, I cannot include my C++ source code on this website — the assignment will no doubt be reused in future semesters and I do not wish to make my code widely available.

Image A - Multiple stacked spheres and reflective “black” polygons

Image B - Colorful spheres and polygons with multiple light sources

Image C - A ring of ellipsoids (transformed spheres) reflecting each other and a central sphere

More on this project:

« Return to main Portfolio page