Ray Tracing

Second year of university - 2006 to 2007

Interest in Ray Tracing

The way computers display three dimensional objects on a two dimensional surface! It was a big jump from the command line to drawing on a screen. The starting point for my enquiries was perspective. The mathematics behind this was relatively simple, so I soon found myself wondering how to shade these objects. Although ray tracing is not the most computationally quick method of producing a realistic looking image, it is the most physically accurate way to do it.

Some Simple Classes

I began by constructing some classes, first three dimensional vectors, then rays and made sure these could all interact and print suitable information about themselves. These classes can be found here and are free for anyone to use:

Basic Ray-Tracing Code

I decided to write the code for fixed objects but moving lights. There is normally no animation involved in ray-tracing as it is so slow at generating images. However, using just a sphere, three lights and a small screen size, it is possible to generate the images fast enough to see a smooth animation. The code for this is below and can be compiled on any platform with SDL.

You can view the project on GitHub.