(DRAFT) CS 348B - Computer Graphics: Image Synthesis Techniques

Homework 3 - Camera Simulation

Assigned Thursday, April 20.   Due Sunday, May 2.

Updated 4/25


Many rendering systems approximate the light arriving on the film plane by assuming a pin-hole camera, which produces images where everything that is visible is sharp.  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 data about 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.  

With this camera simulator, you'll explore the effects of focus, aperture and exposure.  You will empirically characterize the critical points of the telephoto and normal lenses.  Using these data you can  optimize the performance of your simulator considerably.

Step 0

You must have pbrt installed correctly, as in homework 1.  

In addition, you should add . (the local directory) to your PBRT_SEARCHPATH.  

Step 1

Re-read A Realistic Camera Model for Computer Graphics by Kolb, Mitchell, and Hanrahan. 

Step 2: Compound Lens Simulator

Sample Images:


Some conventions:


Step 3: Exploring the way a camera works with your simulator

In this section you'll explore how various choices affect focus, depth of field and exposure in your camera. 

  1. The double gauss and telephoto lenses can be well approximated as a thick lens.  Your first task is to determine the critical points of these lenses to characterize its thick lens approximation.  Rather than tracing single rays, as described in the paper, however, you will take certain special pictures to do so.  This will let you develop a better intuition for the way focus works in a camera.  It's also the way you would characterize a camera lens in the real world!  The procedure is as follows:
    1. Take a picture that tells you the film-side focal point.  The basic idea is to take a picture of an object at infinity and find the film plane distance that makes it sharp.  The film plane's depth is equal to the focal point.  (Why is this?)  We have provided you with a scene file, infinity-test.pbrt, that will get you started.  This file renders an image of the focus target below at a distance of 10m.  You just have to choose and modify the film plane that creates a sharp picture.  Remember that the "filmdistance" parameter specifies the depth of the film from the back (not the front!) of the lens (see the conventions described in Step 2).

    2. Take a second picture with a film depth that gives roughly unit magnification, and that shows you what the depth of the conjugate world focus plane is.  A very tedious way of doing this would be to modify infinity-test.pbrt to put the target closer to the lens, and find the film plane that makes it sharp; then modify the depth of the target and film planes iteratively until you find unit magnification.  A better way is to use a depth of field target, as you would in the real world.  The idea here is to fix a film plane, and take a picture of a ruler on a 45 degree angle.  If the ruler intersects the plane of focus, then the sharpest point on the image of the ruler lets you deduce the depth of the conjugate plane.  We have created a file, dof_target.pbrt, and a test scene, dof-test.pbrt, that includes this object.  The scene is set up so that when you take a picture of the ruler the point of sharpest focus lets you read off the distance of the focal point from the front of the lens.  For example, the following image shows that the focal point is between 70 and 80 mm of the front of the ruler.  The texture for the ruler is shown on the right.


      Note that you may still have to move the target and/or the camera so that a sharp point is within the camera's field of view.  You will also have to find the film depth that gives approximately unit magnification.
    3. From the procedures above you have measured or can calculate values for all the variables in the following diagram of the thick lens configuration:

      D_X is the depth coordinate (measured) for the focal plane in the depth of field test.  D_F is the coordinate of the world-space focal point.  D_P and D_P' are the coordinates of the principal planes.  Note that depending on the lens, D_P' may actually be to the left of D_P, contrary to what's shown in this diagram.  D_F' is the location of the image-space focal point and D_X' is the depth coordinate of the film.  By convention these coordinates are all relative to the front element of the lens, which is not shown.  Note that the focal depth, F, is the same on both sides. Hint: W and W' are simple functions of the focal depth, F, and the magnification M.  You measure M from the image you generate from the depth of field test.  This fact will be needed when you solve for the values of the unknown variables.
    4. Compute the thick lens parameters for the normal and telephoto lenses. How do they differ?  

      We will ask you to report values for these in your write-up.  You may like to discuss strategies to find the correct film plane quickly, etc., but please don't discuss the actual values you compute with other students.
  2. Investigate depth of field.  Use the telephoto lens for this test. 
    1. Set up the camera so that it frames the depth of field target and is focused at 1 meter.  Now take two pictures, one with the aperture set at the maximum radius, and another with it stopped down to 1/2 its radius.  How does the depth of field change?
    2. Now take two pictures with the aperture wide open.  One should be focused at 1 meter and the other at 2 meters.  How does the depth of field change?
  3. Investigate exposure.  Take two pictures with the aperture full open and half open.  How does the exposure change?  Does your ray tracer output the correct exposure?  Why or why not?


Step 4: Web page submission

  1. You will report your findings in a web page again.  To hopefully make the write-up a bit easier, and to make the formatting more consistent, we have created a web page template where you can just fill in the blanks.  
  2. Please send an email to cs348b-spr0304-staff@lists.stanford.edu

That's it!



Please check this FAQ before sending questions to the staff email list.  We will update this list as common issues arise. 

  1. Q: PBRT complains that it can't find realistic.dll or realistic.so.  What should I do?
    A: Make sure that '.' (the local directory) is in your PBRT_SEARCHPATH environment variable.  In this assignment, you will compile a camera plugin (realistic.so/dll) in your working directory. Note that the path is ':' delimited on Linux and ';' delimited on Windows.
  2. Q: Should we be implementing the thick lens approximation described in the paper or a full lens simulation?
    A: Please implement the full lens simulation, which is less work for you and only slightly less efficient computationally.  Implementing the thick lens approximation is a superset of the work, since you need the full lens simulation in order to calculate the thick lens parameters. 
  3. Q: Why are my images so noisy?
    A: Integrating over the surface of the lens, especially for large apertures, requires multiple samples for accuracy.  Too few samples increases the variance of the integral estimate, resulting in noisy images.  The problem is exacerbated in Step 2 by the fact that you will fire many rays at the lens system that will not make it into the world because they will hit the aperture stop.  To drive down the noise, you can increase the number of samples ("integer pixelsamples" parameter in the scene file).  In Step 4 of the system you will also explore optimizing the sampling of the lens system by trying to fire only rays that will actually make it through the lens. This will reduce the noise of your estimation and help your approximation converge more quickly.  If you formulate this as a form of importance sampling, it will only reduce noise in your estimate without introducing bias.
  4. Q: It takes a long time to render just one picture.  It's going to take forever to find the focal point using infinity-test.pbrt!
    A: First, a hint:  the focal point is between 60 and 70 mm for the double gauss lens, and between 200 and 220 mm for the telephoto lens.  
    The next consideration is to speed up your individual renders as much as possible.  Try rendering just the center portion of the film (the bullseye target) and reducing the number of pixel samples.  Finally, try batch-rendering a series of images at different film depths within the suggested range and iterating about the closest pair.  These skills in creating useful quick renders and batch jobs will hold you in good stead on the final project.
    Finally, if you want a more satisfying solution, you could create a modified version of your camera plugin.  This is by no means required for the assignment.  The idea would be to simulate a tilted film plane.  By rendering a single image with such a camera, you can read off the focal depth by correlating the position of sharpest image focus with the corresponding film depth.  Such a tilted plane is available in large-format view cameras, such as the one used by Ansel Adams.  It is practically useful in that you can create pictures where arbitrary planes are in sharp focus -- not just planes that are perpendicular to the axis of the lens as in traditional 35 mm cameras. For instance, you can take a picture facing the horizon where everything on the ground plane is in focus.  
  5. Q: How can the value that you read off the depth of field target ruler be equal to the depth?  It's on a 45 degree angle!
    A: Take a look at dof_target.pbrt.  The ruler is scaled by sqrt(2), to allow you to read off the depth in this convenient way.
  6. Q: What does it mean to "take a picture with a film depth that gives roughly unit magnification"?
    A: Magnification varies with the film depth, as shown in the diagram above. A magnification of M means that lines 1 mm apart on the world-space focal plane appear as M mm on the film plane.  You should measure the magnification on the images that you render.  To do so, you need to know the mm size of the film (defined as the "filmdiag" parameter in the scene file), and it is useful to know that the width of the ruler is 31.617 mm (see dof_target.pbrt).


Miscellaneous Data

You can replace the cones in the rendered scenes with the dragons shown in Figures 6.6-6.9 in the PBRT book.  Just download the dragon.pbrt scene from /usr/class/cs348b/files/geometry, and then comment out the appropriate lines in the hw3 directory scenes.  Be warned that this requires a fair amount of memory to render. 



**  The assignment passes all or almost all our tests.
*   Substantial work was put in, but the assignment didn't pass all our tests.
0  Little or no work was done on the assignment.

*** Extra credit may be given on a case-by-case basis for well done extensions (for any part of the project) that produce superior results.

Copyright © 2004 Pat Hanrahan