Homework 1

For this assignment I created a framework for a stochastic ray tracer in C++. Here are a few important peices of information about the ray tracer:

  • The framework takes a pointer to sampler and a filter, so these two methods can easily be changes. I implemented three sampling stratifies; uniform, jittered and the method presented in Mitchell '91 with tiling and three filters; box, Bartlett and Mitchell-Netravali. These sampling strategies and filters are discussed in more detail below.
  • The ray tracer oversamples using nine samples per image pixel.
  • The ray tracer supports two types of primitives, spheres and triangles. The triangle-ray intersection code is based heavily on the code by Moller and Trumbore.
  • The ray tracer supports only point light sources.
  • I use a lighting model similar to the one presented in Whitted '80. When a point on an object is intersected by a sample ray, the point is shaded using a combination of ambient light, diffuse shading as in Phong (hard shadows are implemented by testing whether the point on the surface is visible to the light) and the value of ray reflected from the surface (to simulate the specular component of lighting). Currently I support a maximum of five reflections before terminating the ray. The diffuse and specular components of the lighting are each scaled by a constant that is defined per object.

Comparison of Filtering and Sampling

  Box Filter Bartlett Filter Mitchell-Netravali Filter
Uniform Sampling
Jittered Sampling
Mitchell Sampling

Note: I used the recommended values of (1/3, 1/3) for B and C in the Mitchell-Netravali filter.

As you can see in the table above, there are certainly differences in the resulting images between various sampling techniques. Due to the fact that I am using primarily spheres and not axis-aligned primitives, to my eye, the uniform filter looks the smoothest. We know from experience, however, that uniform filters can run into a great deal of trouble when scenes with axis-aligned primitives are animated, because you only get three (in the case of nine samples per pixel) different color gradations for the axis-aligned edges. In looking at the filtering techniques, it is much harder to make a judgment; however, to my eye the box filter actually did best on the test scene I created. It does, as expected, create box shaped artifacts, but it seems to do a slightly better job of not over-exposing the pixels around the edges of the spheres. Looking closely at the blow-ups below does show (to my eye) that the Mitchell-Netravali filter works better on anti-aliasing the edge of the triangle, as we would expect. All in all, not exactly the results we expected from reading previous work, however, I think final judgment will have to be reserved for when more complicated scenes can be rendered and the results can be viewed.

Box Filter Bartlett Filter Mitchell-Netravali Filter

The source can be downloaded here.