CS 551/651: Image Synthesis

Assignment 3: Realistic Camera Simulation

Due: Thursday, March 3

Description

Many rendering systems approximate irradiance on the film plane by sampling the scene through an infinitesimal aperture (i.e a pin-hole). However, this technique fails to capture important imaging characteristics of multi-lens cameras such as depth of field, distortion, vignetting and spatially varying exposure. In this assignment, you will implement a realistic camera model capable of capturing these effects. Specifically, your camera model will simulate the traversal of light rays through complex lens assemblies as shown above. This assignment is divided into the following parts:

Step 1

Read the paper A Realistic Camera Model for Computer graphics, which describes in detail the algorithms you will need to implement. You should be comfortable with the concepts before you attempt to write any code for this assignment. Also, you may want to look over a text on basic lens optics and transformations.

Step 2 (Part 1)

Download this zip file containing the skeleton code and lens descriptions you will need for part 1 of this assignment. The lensview application is a cross-platform, OpenGL program that parses a lens specification file and draws the lens system. We intend for you to use this as a starting point for building your camera simulator, but feel free to start from scratch if you prefer. The zip file consists of the following:

As described in the paper, the lens specifications are defined as a list of spherical elements, each with a given radius, index of refraction, aperture and position. The axpos field is the axial thickness of an element as measured from the previous element in the list. The aperture stop is the listing with radius and N (index of refraction) set to zero. The lensview code reads these parameters and builds a simple data structure to represent the lens system.

Load any one of the lens files using the reference implementation (e.g. lensview wide.dat) and you will see by example the list of requirements for part 1 of this assignment. (Note that key and mouse controls will print to the terminal when the program is loaded). Specifically, you need to calculate several values - all described in the paper - that characterize the lens system. These include:

To compute these parameters you need to design and implement a set of routines for tracing through the exact lens system as well as a thick lens approximation defined by the cardinal points F, F', P and P'. The reference implementation demonstrates this in two modes by tracing several rays from the image plane until they focus in front of the lens assembly. You should add the same feature to your simulator, allowing the user to toggle between an exact and approximate raytracing using the thick lens transformation.

Conventions

Suggestions

Setting fstop and aperture

The fstop parameter relates the focal length to the effective aperture (exit pupil) of the lens system: fstop = fl / effective aperture, where fl is the focal length. For setting the aperture size, a more useful equation is: fstop = 1 / (2 * sin(theta)), which relates the f number to the angle defining the cone of light passing freely through the lens system. You can find a derivation of this equation (illustrated below) in several optics texts or online.

With this equation you can compute theta for any fstop value. To find the size of the physical aperture (which is later used to compute the exit pupil), simply trace a ray at angle theta from the central axis through the lens system. The intersection point of this ray with the aperture plane defines the radius of the aperture. You can use this to compute the minimum possible fstop, which corresponds to the maximum possible theta for a given lens. Use the reference implementation to check your aperture size for different f numbers.

Thick lens transformation

The paper describes a way to implement the thick lens approximation as a 4x4 matrix. It's important to note that the transform they give assumes that P is the origin. Using the coordinate system you are given in lensview, you have to be careful about the position of points you want to transform. For example, if you are calculating the exit pupil, you need to do: i = Te, where e is a point on the top edge of the physical aperture, T is the thick lens matrix, and i is the image of e. However, for this to work correctly you need to translate e.z by the position of P, so you get: e = e - P, where P is a signed value. Then after you apply the transformation you need to translate the result back: i = i + P to get the proper distance along the axis. (You probably had to do something similar to this when computing ray/sphere intersections for each lens element). The same is true for imaging a point on the other side of the thick lens, except you want to replace P with P'. The paper discusses this, but it might not be clear given the lensview coordinate system.

Step 3 (Part 2)

For part 2 of this assignment, you will use your camera simulator to create a realistic camera plugin for pbrt. You will use this model to explore effects such as depth of field, field distortion, focusing, aperture and exposure. Once you've completed part 1, this should be relatively painless. You should be able to port your code directly to pbrt with only slight modifications. Click here to download a zip file containing the skeleton code the realistic camera plugin. The file also contains several pbrt scene files that demonstrate how to use the realistic camera type. The list of input parameters are as follows (all values are in millimeters):

Requirements

The scene files in realistic.zip provide you with examples of how to test the accuracy of your camera simulator. The 'examples' folder contains references images corresponding to each of the pbrt scenes. Your implementation should produce similar (ideally identical) results for these examples. The zip file contains a reference implementation (realistic.dll) you can use to verify your results.

Suggestions

Submission

Write a short web page describing the algorithms you used in your camera simulator. Email the TA as usual. The web page should consist of: