CS348b: Computer Graphics: Image Synthesis Techniques

Assignment 2: Realsitic Lens System Simulation


Handed out: April 24

Due: May 8




Many rendering systems (including lrt) approximate irradiance on the film plane by sampling scene radiance through an infinitesimal aperture (i.e a pin-hole) or by using a thin lens approximation. Unfortunately, these techniques are geometrically and radiometrically incorrect and can therefore 'lay to waste' much of the physically accurate computation involved in realistic image synthesis. A realistic camera model can accurately compute film irradiance by tracing sample rays through a multi-lens system, correctly revealing effects such as depth of field, vignetting and film exposure.


Step 1


Re-read the paper “A Realistic Camera Model for Computer Graphics”, by Kolb, Mitchell, and Hanrahan, proceedings of SIGGRAPH 1995 (web page).


Step 2


Next, retrieve a copy of the skeleton files, example scenes, and lens description files for this assignment and copy them to your home directory.

A stub implementation of the camera implementation in the file /usr/class/cs348b/hw2/realistic.cc.  Copy this file to the cameras/ directory in your lrt directory and edit the PYWEB_CAMERAS_CCFILES line of the Makefile.filelist file to add realistic.cc to the camera implementations that are compiled.  Because lrt is written with a plug-in architecture, it is not necessary to edit any of the rest of lrt’s source code to add the camera.  Comments in realistic.cc will explain the method you need to implement for the new camera model.


There are three main tasks for this assignment:

The lens files can be found in /usr/class/cs348b/hw2/lenses.  We have prepared a couple of scene files for you to render with your implementation.  These can be found in /usr/class/cs348b/scenes/camera*.rib.  We will put reference images in /usr/class/cs348b/hw2 folder shortly.  You should make sure your implementation can render all of the examples correctly.




Below are some frequently asked questions which should be helpful.  Be sure to check back here before emailing for help.







The fstop relates the effective aperture of the lens system to the focal length by the following relationship:

Fstop = (focal length) / (effective aperture)

You can compute the focal length using the Thick Lens Approximation mentioned above.  This equation however is not really that usefull since the effective aperture is different than the physical aperture since the lens elements between the aperture and the image plane will change the image of the aperture.  A more useful equation is:

Fstop = 1 / (2*sin pheta)

Pheta defines the cone of light that comes into the focal point from parallel rays.  We can compute the size physical aperture by tracing a ray through the lens system from the film side focal point.    Where this ray intersects the plane containing the aperture provides the size of the physical aperture, as shown in the following figure:



                        (Note that it is a sine function, not tangent which is not exactly intuative.  This is due to the principle planes not really being planes.)



sample->lensX, sample->lensY provide a sample point in the range [0,1] evenly distributed across the range.  In order to generate a distribution which is evenly distributed in a circle (the shape of the exit pupil), use the ConcentricSampleDisk function.  Be sure to read the Camera chapter (ch. 6) of the LRT book for more information.





Assuming all lengths are positive in the above picture:

For an object to be in focus, the following relationship should be true:


1/a + 1/a’ = 1/f  where f is the focal length as shown above.


We can substitute a and a’ to get:


1/(fd + p) + 1 / (film – p’) = 1 / f

  where fd is the focus distance and p, p’ are the principle planes


We know p, p’ and fd so we can simply solve for film using simple algebra.









Reference Results


Here are results from my reference implementation.  Please let me know if you think there any errors in these images.



Tiff Image: /usr/class/cs348b/hw2/realistic.tiff



Here is the telephoto lens fstop = 5.6


Wide lens fstop = 4.0


Fisheye lens fstop = 4.0



Tiff Image:  /usr/class/cs348b/hw2/focustest.tiff







Turn in your finished homework using the cs348b submit script:


cd my-lrt-directory/cameras



Make sure you hand in realistic.cc and a README file. The README should contain instructions for compiling and running your code, and a description of anything non-intuitive you've done. Please do not submit any executables or object (.o) files. We'll be building your submissions ourselves, and those just take up space.




This homework, like the other programming assignments, will be graded according to the following system:


0 - Little or no work was done
* - Significant effort was put into the assignment, but not everything works correctly.
** - The algorithm you implemented was functionally complete; it passed all of our tests.
*** - Your implementation was substantially faster or more flexible than a straightforward implementation.