CS348b2007

Assignment 3: Camera Simulation

Due: Friday May 8th, 11:59PM

Please add a link to your final writeup on Assignment3Writeups.

lenses

Description

Most rendering systems generate images where the entire scene is in sharp focus, thus mimicking the effect of a pinhole camera. In contrast, real cameras contain multi-lens assemblies with different imaging characteristics such as limited depth of field, field distortion, vignetting and spatially varying exposure. In this assignment, you'll extend pbrt with support for a more realistic camera model that accurately simulates these effects. Specifically, we will provide you with descriptions of real wide-angle, normal and telephoto lenses, each composed of multiple lens elements. You will build a camera plugin for pbrt that simulates the traversal of light through these lens assemblies onto the film plane of a virtual camera. With this camera simulator, you'll explore the effects of focus, aperture and exposure. Once you have a working camera simulator, you will add simple auto-focus capabilities to your camera.

Step 1: Background Reading

Before beginning this assignment you should read the paper "A Realistic Camera Model for Computer Graphics" by Kolb, Mitchell, and Hanrahan. This paper is one of the assigned course readings. You should also review parts of Chapter 6 in pbrt.

Step 2: Getting Up and Running

Starter code and data files for Assignment 3 are located at http://graphics.stanford.edu/courses/cs348b-07/assignment3/assignment3.zip.

Step 3: Setup the Camera

Notice that in this assignment the pbrt scenes specify that rendering should use the "realistic" camera plugin that you are implementing in this assignment. The realistic camera accepts a number of parameters defined in the pbrt scene file. The most important of these parameters include: the name of a lens data file, the distance between the film plane and the location of the back lens element (the one closest to the film), the diameter of the aperture stop, and the length of the film diagonal (distance from top left corner to bottom right corder of film). The values of these parameters are passed in to the constructor of the RealisticCamera class. All values in both the pbrt file and in the lens data file are in units of millimeters.

Camera "realistic" 
        "string specfile" "dgauss.50mm.dat" 
        "float filmdistance" 36.77
        "float aperture_diameter" 17.1
        "float filmdiag" 70 

The .dat files included with the starter code describe camera lenses using the format described in Figure 1 of the Kolb paper. Your RealisticCamera constructor should read the specified lens data file. In pbrt, the viewing direction is the positive z-direction in camera space. Therefore, your camera should be looking directly down the z-axis. The first lens element listed in the file (the lens element closest to the world, and farthest from the film plane) should be located at the origin in camera space with the rest of the lens system and film plane extending in the negative-z direction.

Each line in the file contains the following information about one spherical lens interface.

lens_radius  z-axis_intercept  index_of_refraction  aperture

More precisely:

Note that exactly one of the lines in the data file will have lens_radius = 0. This is the aperture stop of the camera. It's maximum size is given by the aperture value on this line. It's actual size is specified as a parameter to the realistic camera via the pbrt scene file. Also note that the index of refraction of the world side of the first lens element is 1 (it's air).

Step 4: Generate Camera Rays

4 samples per pixel

hw3_telephoto_4 hw3_dgauss_4

hw3_wide_4 hw3_fisheye_4

512 samples per pixel

hw3_telephoto_512 hw3_dgauss_512

hw3_wide_512 hw3_fisheye_512

Hints

  1. ConcentricSampleDisk() is a useful function for converting two 1D uniform random samples into a uniform random sample on a disk. See p. 270 of the PBRT book.

  2. You'll need some data structure to store the information about each lens interface as well as the aperture stop. For each lens interface, you'll need to decide how to test for intersection and how rays refract according to the change of index of refraction on either side (review Snell's law).
  3. For rays that terminate at the aperture stop, return a ray with a weight of 0 -- pbrt tests for such a case and will terminate the ray instead of sending it out into the scene.
  4. Pay attention to the coordinate system used to represent rays. Confusion between world space and camera space can be a major source of bugs.
  5. As is often the case in rendering, your code won't produce correct images until everything is working just right. Try to think of ways that you can modularize your work and test as much of it as possible incrementally as you go. Use assertions liberally to try to verify that your code is doing what you think it should at each step. It may be worth your time to produce a visualization of the rays refracting through your lens system as a debugging aid (compare to those at the top of this web page).

Step N: Submission

Grading

This assignment will be graded on a 4 point scale:

last edited 2007-05-09 01:57:15 by KayvonFatahalian