Basic Ray Tracer
February 12, 2005

Description
This ray tracer creates an image that contains 1 light source, 2 spheres, a checkerboard ground plane and a background. The lighting in the scene includes ambient, diffuse and specular effects on Objects including shadows.

Source Code
The source code consits of the following files:

  • rayTracer_03.C
  • vector.H
  • vector.C
  • color.H
  • color.C
  • ray.H
  • ray.C
There is a Make file that compiles the program

Problems
While writing this raytracer there were several things that gave me problems,

  1. Specular
  2. Shadows
  3. Arbitrary Aspect Ratio

Final Rendered Image

Specular Problem
When I was working with the specular I was getting a strong washed out specular area.


Shadow Problem
When implementing shadows at first I had a self shadowing problem, but that wasn't hard to fix. I just set a tolerance when checking for a ray intersection. After that I could see any shadows and couldn't figure out why they were showing up. It took me a couple of days to track down the problem. It turned out that I just set the light intensity to high and it was washing out the shadows. D'oh!

Arbitrary Aspect Ratio
The ray tracer works with out any squashing when it is creating an image that is square. However, when you want to create an image that isn't square, say 640 x 480, then the image becomes squashed. I've gone over the ratio several times and keep coming up with the same answer, but it doesn't work.

dy = 0.5 + (double)i*(1.0/HEIGHT);
dx = (-WIDTH/2*HEIGHT) + (double)j*(1/HEIGHT);