= Assignment 3 Camera Simulation = == Name: Ranjitha Kumar == == Date submitted: 7 May 2006 == == Code emailed: 7 May 2006 == == Compound Lens Simulator == === Description of implementation approach and comments === The first part of the assignment was to implement RealisticCamera::GenerateRay. There were two main tasks in the function: first, you had to set up a ray, and then you had to trace that ray through the lens system. To setup a ray, you have to choose a point on the film plane, the origin of the ray, and a point on a disk with a raidus that is equal to the radius of the aperture of the back lens element, which will determine the direction of the ray. * To choose the point on the film plane, which is perpendicular to the z-axis, the program maps the point (sample->imageX, sample->imageY) given in raster coordinates to camera coordinates. Using the film diagonal given in mm, the program determines the dimensions in camera space, and centers the film in the xy plane. The z-coordinate of the ray is determined by adding up all the axpos's of the lens system and the film distance. === Final Images Rendered with 512 samples per pixel === || || '''My Implementation''' || '''Reference''' || || '''Telephoto''' ||attachment:telephoto512.jpg|| http://graphics.stanford.edu/courses/cs348b-06/homework3/hw3.telephoto_512.png|| || '''Double Gausss''' ||attachment:dgauss512.jpg||http://graphics.stanford.edu/courses/cs348b-06/homework3/hw3.dgauss_512.png|| || '''Wide Angle''' ||attachment:wide512.jpg||http://graphics.stanford.edu/courses/cs348b-06/homework3/hw3.wide_512.png|| || '''Fisheye''' ||attachment:fisheye512.jpg||http://graphics.stanford.edu/courses/cs348b-06/homework3/hw3.fisheye_512.png|| === Final Images Rendered with 4 samples per pixel === || || '''My Implementation''' || '''Reference''' || || '''Telephoto''' ||attachment:telephoto4.jpg|| http://graphics.stanford.edu/courses/cs348b-06/homework3/hw3.telephoto_4.png|| || '''Double Gausss''' ||attachment:dgauss4.jpg||http://graphics.stanford.edu/courses/cs348b-06/homework3/hw3.dgauss_4.png|| || '''Wide Angle''' ||attachment:wide4.jpg||http://graphics.stanford.edu/courses/cs348b-06/homework3/hw3.wide_4.png|| || '''Fisheye''' ||attachment:fisheye4.jpg||http://graphics.stanford.edu/courses/cs348b-06/homework3/hw3.fisheye_4.png|| == Experiment with Exposure == || '''Image with aperture full open''' || '''Image with half radius aperture''' || || attachment:dgauss512.jpg || attachment:exp_dgauss.jpg || === Observation and Explanation === When you reduce the aperture radius by one half and keep the shutter speed the same, you expect that the image will be darker and noisier because fewer rays make it through the lens system and onto the film plane. This effect is illustrated by the images rendered above. Also notice how the foreground in the image on the right appears sharper than that of the image on the left; making the aperture smaller increases the depth of field because the circles of confusion are forced to be smaller; this concept is better illustrated by the stopped down renderings with the telephoto lens (see Extras below.) When you half the aperture size, you have decreased the photograph exposure by 2 stops. == Autofocus Simulation == === Description of implementation approach and comments === ...... === Final Images Rendered with 512 samples per pixel === || || '''Adjusted film distance''' || '''My Implementation''' || '''Reference''' || || '''Double Gausss 1''' || 62 mm || attachment:afdgauss_closeup.jpg || http://graphics.stanford.edu/courses/cs348b-06/homework3/hw3.afdgauss_closeup.png|| || '''Double Gausss 2''' || 40 mm || attachment:afdgauss_bg.jpg ||http://graphics.stanford.edu/courses/cs348b-06/homework3/hw3.afdgauss_bg.png|| || '''Telephoto''' || 117 mm || attachment:aftelephoto.jpg ||http://graphics.stanford.edu/courses/cs348b-06/homework3/hw3.aftelephoto.png|| == Extras == === Stop Down the Telephoto Lens === || '''Decreased 4 stops''' || '''Decreased 4 stops + exposure 4X in Photoshop''' || '''Full Aperture''' || || attachment:exp_telephoto1.jpg || attachment:exp_telephoto2.jpg || attachment:telephoto512.jpg || By decreasing the aperture radius to one fourth its original value (4 stops), you can achieve a greater depth of focus. To better illustrate the increase in depth of field I created the rendering in the middle by taking the rendering to the left and changing the exposure to 4 in Photoshop. Notice how the near foreground and background, which appeared fuzzy in the full aperture rendering, now appear sharp and in focus. On an regular camera, if you increased the shutter speed by 16 times, you would get the image in the middle minus the noise. === More Complex Auto Focus === || '''Regular - 39 mm''' || '''Macro-Mode - 42 mm''' || || attachment:af_test1.jpg || attachment:af_test2.jpg || As suggested in the assignment handout, when rendering with multiple autofocus zones, I specify in the scenefile a "string afMode", which has either "macro" or "bg" as input, telling the camera whether to prioritize foreground or background objects. (The afMode is set to "bg" by default.) Then, for each afZone I calculate the distance at which the afZone is the sharpest using the same method as above. If the scene has specified "macro" mode, I set the film distance to be the largest distance out of all the "in focus" distances calculated; if the scene is in "bg" mode, then I set the film distance to be the smallest out all of them. (Closer objects are focused further back, and farther objects are focused closer to the lens.) The renderings above were made using two autofocus regions. The first autofocus region was sharpest at 39 mm and the second autofocus region was sharpest at 42 mm; so in "bg" mode, the distance given by the first autofocus region was the one that was used, and in "macro" mode, the distance given by the second autofocus region was the one that was used.