# Assignment 3 Camera Simulation

## Compound Lens Simulator

### Description of implementation approach and comments

My implementation is straightforward. I tried to push as much of the repetative calculations outside of loops or frequently-called methods to maximize performance. I also heavily utilized PBRT's vector math utilities. I used an STL vector to hold structs of the lens data (read from the dat file) and used a const_reverse_iterator to read through them from film->world. Each intersection was calculated with a snippet of code I nabbed from Povray, and the refraction was calculated using the code from the Snell's law lecture slide page.

It took me the longest time to iron out the last problem I had. I was stuck on it for about 3 days. At any rate, the problem was that I wasn't using the correct n-number for the index of refraction of the lenses. The file format gave the next n-number in order from the world->film, but the light is traced from the film->world, and my n's were off by one.

Also, the 512 sample renderings of the dgauss and wide lenses are taking much longer than expected. The last estimated completion time on my machine (3.0 GHz P4 w/ HT, 2GB RAM, Win XP SP2) was about 44 hours after the deadline time. I'll post them whenever they complete, but the code will be submitted before the deadline.

I manually adjusted the exposure and gamma on these results in photoshop, so they not match EXACTLY, but they look good, don't you think?

### Final Images Rendered with 512 samples per pixel

 My Implementation Reference Telephoto Double Gausss Wide Angle Fisheye

### Final Images Rendered with 4 samples per pixel

 My Implementation Reference Telephoto Double Gausss Wide Angle Fisheye

## Experiment with Exposure

 Image with aperture full open Image with half radius aperture

### Observation and Explanation

Naturally, as we've discussed in class, a smaller aperture will increase the depth of field. That is, the area of the scene that is in-focus will be larger. The renderings above clearly show the difference in depth of field between the apertures. One important thing to note, however, is that with the reduction of the aperture size, we also have a drop in the amount of light that is allowed through the lens, which is why the image appears darker.

## Autofocus Simulation

### Description of implementation approach and comments

Unfortunately, I ran out of time before being able to attempt this portion of the assignment. As you've read the previous bug remained elusive for quite some time, and I've run out of late days (1 for HW2, and 2 for HW3).