Project 2

A full basic ray tracer with Lambertian shading and simple diffusive material model


Images have been scaled down. Click on images for fullsize view.

Image Specifications:
Left Image
Camera at (1, -18, 3.5), looking at (-1, 1, 2), with up defined as (0, 0, 1)

White point light at (20, 30, 100)
Red point light at (-40, -30, 50)
Soft white global ambient light

Red sphere at (-2, -0.5, 2), with radius 1.2
Cyan sphere at (1.5, 1, 4), with radius 2
Invisible magenta spheres at (25, 25, 120) and (-5, -5, -20) with radii 10 and 10
Gray plane running through (0, 0, -0.1) with normal vector (0, 0, 1)

Right Image
Same as above but with camera at (1, -18, -3.5)

Performance evaluation here

Creative Images:

This image demonstrates my GradientBackground class (a ConstantBackground
is visible in the reference image above). Note how the background color fades smoothly from
cyan at the bottom to red at the top.

The rest of the image shows a plane (tilted to expose more of the background) and a white
sphere lit from above by two differently colored lights.

This is an interesting image showing a sphere casting a shadow on the corner formed
by two planes intersecting at right angles, and another sphere casting a shadow on the first
sphere.

Design choices:
I tried as much as possible to keep the structure of the ray tracer modular, allowing for addition
of features later, as well as keeping the design simple for the sake of future class projects.

As for class interfaces, I tried to create abstract base classes with simple interfaces that capture
the total essence of that family of classes. A simple example is my Background class, which
contains a single pure virtual method, named color(int j, int i). A background object needs
to be able to tell what color the background is at each pixel in the final image. Therefore, it has
the one method. Whatever state is necessary to make that determination is kept in concrete subclasses
of Background. This is a simple example, and a common practice in C++ programming, but
nonetheless I have tried to apply the practice to all aspects of my ray tracer.

Extra Credit 3:

These images show the same scene, through different cameras. Each one has:

  1. Red sphere at (-3, -5, 0)
  2. Green sphere at (0, 0, 0)
  3. Blue sphere at (3, 5, 0)
The camera sits at (0, -20, 0) and looks towards the origin, with its up vector
set to (0, 0, 1).

In the left image, a PinholeCamera is used. Note that the spheres
are visibly at different distances from the camera. In the right image, an
OrthographicCamera is used, destroying the perception of distance.