Assignment 4

Fabian Prada

This assignament explores the simulation of a realistic camera.

Part I: Ray Tracing Through a Lens System

The construction of the realistic was done as specified in [1]. My implementation consists of three classes:

1) LensElement:

Attributes:


Methods:

2) apertureStop:

Attributes:


Methods:

3) lensSystem:

Attributes:


Methods:

Implementation Procedure:

  1. Given a sample in Raster coordinates it is initially transformed to Film coordinates at Camera Space.

  2. Using the lensU and lensV values of the sample, and ConcentricSampleDisk(), I defined a point in the aperture disk of the back element of the len system. The ray to be evaluated is constructed with origin at the sample position in the Film and direction to the point in the aperture disk of the back elemenent.

  3. The ray trajectory through the lens system is calculated using the method evaluateRayTrajectory(), which invokes the method generateRefractionDirection() at each element. evaluatePassApertureStop() is called between the two elements where the aperture stop is located.

  4. If the ray gets the front element of the lens system, the this ray is transformed from Camera Sapce to World Space and it is passed to the renderer.

Results:

Camera 4 Samples 512 Samples
DGauss 50mm hw3_dgauss4Samples.jpg hw3_dgauss512Samples.jpg
Wide 22mm hw3_Wide4Samples.jpg hw3_Wide512Samples.jpg
Telephoto 250mm hw3_Tele4Samples.jpg hw3_Tele512Samples.jpg
Fisheye 10mm hw3_Fish4Samples.jpg hw3_Fish512Samples.jpg

Part II: Autofocus Simulation

My implementation of Autofocus is based on estimating the position of the Princial Planes and Focal Points as described in [1]. The procedure I used to find such points was shooting parellel rays from both sides of the lens system as suggested in [1]:

  1. I generate 20 rays parallel to z axis from 1mm behind the back element of the lens system and distributed vertically. I took as principal focal point F the mean of the z value where the rays intersected the xz plane. The principal plane P was estimated as the mean z value where the refracted rays intersected the original rays.

  2. The secondary focal point F' and the secondary plane P' were estimated analogously, but now the test rays where generated 1mm before the front element and in direction to the the Film.

  3. To calculate the focus adjustment as suggested in [1] I required to konw the object position. Then I generated rays from the Autofocus Zone in the Film (at Camera Space) that cross the lens system and go to the World. Using the scene class I was able to calculate the intersection of the ray in the World Space. Using the inverse of the CameraToWorld transform I was able to get the intersection point Camera Space coordinates.

  4. From the equation 1/z'-1/z=1/f', in [1], (z=distance from P to the object, z'=distance from P' to film, f'=distance P' to F'), and all the previous information, I was able to calculate z', and consecuently, the new position of the film.

  5. Finally the film was moved to the new position In order to have the desired object at focus.

  6. Results:

    Scene In Focus Out of Focus
    DGauss 50mm Close Up hw3_afdgauss_closeup_InFocus.jpg hw3_afdgauss_closeup_OutFocus.jpg
    DGauss 50mm BG hw3_afdgauss_bg_Focus.jpg hw3_afdgauss_bg_OutFocus.jpg
    Scene In Focus 1 In Focus 2 Out of Focus
    DGauss 50mm Spheres hw3_afspheres_Focus1.jpg hw3_afspheres_Focus2.jpg hw3_afspheres_NoFocus.jpg
    Scene Default Focus Close Focus Far Focus
    DGauss 50mm Bunnies hw3_bunnies_NoFocus.jpg hw3_bunnies_CloseFocus.jpg hw3_bunnies_FarFocus.jpg

    Reference

  7. [1]"A Realistic Camera Model for Computer Graphics".Craig Kolb, Don Mitchell, and Pat Hanrahan. Computer Graphics (Proceedings of SIGGRAPH '95), ACM SIGGRAPH, 1995, pp. 317-324