For this assignment, you will add a more realistic camera model to lrt. The new camera model will support depth of field, very limited motion blur, and two different kinds of shutters.
The new lrt in /usr/class/cs348b/software/lrt/lrt.tar.gz contains all the changes that have been published up to this point, as well as the modifications to the camera framework to make this assignment possible. All of your changes will be made in the file mbdofcamera.cc. In that file, you will see a single function, GenerateRay. You will be required to create a ray given a 5-tuple of sample values. You should familiarize yourself with the function PinholeCamera::GenerateRay in camera.cc to see how this is done for a simple camera with an infinitely small aperture.
First, you should add depth of field to lrt. The 5-tuple of samples passed to GenerateRay should be interpreted as follows:
Using sample and sample for the film location, generate a sample on the aperture using the random numbers in sample and sample. Armed with these four numbers (x,y,u,v), you can generate the appropriate ray to trace. Refer to your answer to question 3 of assignment 2 for the mathematics behind this construction.
GenerateRay should return true if the computed ray is valid, and false otherwise.
The DepthOfField command sets the parameters necessary to compute depth of field. For more detail, check out the documentation under RenderMan Resources.
The three parameters specified by the DepthOfField command are available as members of the Camera class as FStop, FocalLength, and FocalDistance. You should probably not mess with the FocalLength parameter in the sample file; just adjust the f-stop and focal distance.
Note that you can issue the command
Which will set the aperture to RI_INFINITY. If this is the case, the FocalDistance and FocalLength are undefined, and everything will be in focus (i.e., the aperture is a pinhole).
To switch from the default pinhole camera to your fancy camera, put the
Option "camera" "type" "mbdof"
at the top of the RIB file. It is important that this line appear before the projection is set, or any other camera options, as it will construct a new camera object, and previous settings will be lost.
The fifth sample parameter is another uniformly distributed random number between 0 and 1, which can be used for sampling a time interval. You will notice that there are two CameraToWorld transformations; these correspond to the camera transformations at time t=0, and t=1.
For this assignment, you may assume that the camera is the only moving object in the scene, and that the camera movement is purely translational.
MotionBegin [0 1] Translate 0 10 0 Translate 0 20 0 MotionEndThis needs to appear before the WorldBegin command.
Finally, you should simulate the behavior of two different types of shutters: iris shutters and stripe shutters. Andrew Glassner has written an excellent article on shutters. (The article should be available for download from any Stanford computer).
An iris shutter is circular. It starts closed, and opens radially to the full aperture of the lens before closing again. It is closed at t=0, and again at t=1. Obviously, the shutter cannot open and close instantaneously. For this part, you should assume that the radius of the shutter grows from 0 to the full aperture linearly at some rate R, and closes again at the same rate.
For example, if R=10, the iris opens with a linearly growing radius from t=0 until t=1/10. It begins to close (again linearly) at t=9/10. At times when the iris is not fully open, it should be considered to limit the aperture of the lens. Note that it does not make sense for R to be less than 2.
A stripe shutter slides a rectangular window of a certain width across the film plane. The window can move left, right, up, or down. As in the case of the iris shutter, the shutter is closed (i.e., the window is off to one side) at t=0, and it closes again (i.e., the window is at the other side) at t=1. (Note: This is not exactly how this is implemented in real cameras, but it will serve for our purposes. See the Glassner Article for more information).
The Camera class also contains the floats IrisRate and StripeWidth, which correspond directly to the values set in the RIB file.
Finally, the Camera class also has a variable called StripeDirection, which can be compared to the constants LRT_UP, LRT_DOWN, LRT_RIGHT, and (you guessed it), LRT_LEFT to figure out what direction the stripe should be moving.
ALSO: create a web page containing at least three renderings of a single, original scene with varying camera parameters. At least one of the images should clearly show artifacts from a shutter simulation, and be labeled as such. Label each image with the parameters used to create the scene: Motion (if any), f-stop, focal distance, shutter type, shutter parameters, number of samples per pixel. This scene doesn't need to be complex, just a few simple geometric objects arranged in such a way as to show off features of your camera system. If you implement any features above and beyond what's described here, be sure to show them off on your web page. The web page should include the images created, as well as the RIB source that made them. Include a URL to the web page in your README. DO NOT omit this step. Hint: For your final web-page renderings, turn up the number of samples per pixel. You'll be more pleased with the results, and it's worth the wait.
This homework will be graded according to the following system:
Copyright © 2001 Pat Hanrahan