Steve Kincaid

Shane Hill

Matt Lindquist

 

 

Depth of Field

Implementing depth of field effects in 3D renderings

Depth of field is a noticeable component in almost any still image and moving image that you see.  This effect results in the blurring of foreground and background objects within the field of view.  We feel this is a compelling aspect of any 3D image giving creative direction to the viewer’s focus by de-emphasizing non-critical elements of the image.

Glossary

A few terms to get cozy with in order to make sense of DOF when ray tracing images:

·       DOF - Depth of Field – a volume of space within a scene that is in sharp focus.

·       CPOFCritical Plane of Focus – the 2D plane that is the critical focal distance from the camera (eye) POV.

·       COCCircle of Confusion – (details below) the area on the (virtual) film plane that gathers light from a single point in the scene.  The more that single point is out of focus, the larger the COC.

Problem Statement

Consumer media as well as our personal media such as family photos and videos are shot though a photographic lens with a limited DOF.  This is what we are used to seeing.  By adding DOF to computer rendered images, we can greatly enhance the ‘realism’ of the image.  Additionally, DOF provides artistic tools to guide viewer focus to the subject in our scene.

glasses.jpg

Figure 1 – A very realistic scene that is computer rendered.  Image source

 

Camera lens effect

fig23-02.jpg

Figure 2 – COC though a lens – Image Source

Follow the solid line from the bottom of the tree object (an out of focus item in our scene) to the (virtual) film plane.  The light from a single point in a scene is scattered over an area of the film known as the Circle of Confusion.  The “circle of confusion” is dependent on:

·       Size of lens aperture

·       Difference between the distance to the:

o   critical plane of focus

o   object

 

Programming Solutions

There are multiple ways to implement depth of field in 3D rendering.  Following are some that we are considering with related pseudo code.  Final research paper will include diagrams and more intensive pseudo code.

1.     Post-Render light gathering

·       Render the entire scene into an image buffer SharpImage[x][y] (2D color array).

·       Determine max diameter of circle of confusion.

·       Based on value of depth-map, re-render each pixel by averaging values together inside the circle of confusion (COC).  COC size for a given pixel is calculated as a linear approximation from 0-100% of COC-max depending on the difference between the object and the critical plane of focus.

o   If COC is smaller than 1.0 pixel, then use SharpImage[x][y].

2.     Down Scale Blur, Post-render averaging

·       Render the entire scene into an image buffer SharpImage[x][y] (2D color array).

·       Downscale the image (1/16) into BlurBuffer[(int)x/16][(int)y/16] = SharpImage[x][y]

·       Perform a 3x3 Gaussian Blur on BlurBuffer[][]

·       Based on value of depth-map, re-render each pixel by averaging values Between SharpImage[][] and BlurBuffer[][] on a sliding scale to control blur effect

o   e.g. 75% blur (SharpImage[x][y] * 0.25 + BlueBuffer[x/16][y/16] * 0.75)

3.     2D Blur DOF Simulation

·       Useful for times when depth is not known such as with a 2D image

o   Size of COC user configurable

·       Post Render Blur effect created by taking pixel color by pulling from each surrounding pixel (Left Color + Right Color + Top Color + Bottom Color)/4

·       Outside the COC gets the blur but Inside COC is the original unmodified sharp image

·       This is not actually real DOF, but a simulation

·       What is in or out of focus is user controlled/defined

User Selectable Options

It’s possible that we will implement more than one method (depending on the best-fit for the intended project size and scope).  If so, users will have a selection dropdown from the UI where they can select a DOF algorithm, then re-render the image.

Additionally, it might be fun (and easy) to allow users to set the depth of the critical plane of focus as a percentage of the distance to the max distance (back of the scene).  It also might be interesting to control the max size of the COC.

Results

Results

              Down Scale Blur                                                         Post-Render Light Gathering                                                      2D Blur Simulation

Down_DOF_Test.bmpSim_DOF_Test.bmpPixelAvg_DOF_Test.bmp

Down_DOF_Test2.bmpPixelAvg_DOF_Test2.bmpSim_DOF_Test2.bmp

 

Down_DOF_Test_Ball.bmpPixelAvg_DOF_Test_Ball.bmpSim_DOF_Test_Ball.bmp

Down_DOF_Test_Panda.bmpPixelAvg_DOF_Test_Panda.bmpSim_DOF_Test_Panda.bmp

Sources

Real Time Rendering (class textbook) pp 486-489

http://en.wikipedia.org/wiki/Depth_of_field

http://developer.amd.com/media/gpu_assets/Scheuermann_DepthOfField.pdf

Fernando, Randimi. 2004 “GPU Gems” http://http.developer.nvidia.com/GPUGems/gpugems_ch23.html

Fernando, Randimi. 2008 “GPU Gems 3” http://http.developer.nvidia.com/GPUGems3/gpugems3_ch28.html

Haeberli, Paul, and Kurt Akeley. 1990. "The Accumulation Buffer: Hardware Support for High-Quality Rendering." Computer Graphics 24(4). Available online at http://graphics.stanford.edu/courses/cs248-02/haeberli-akeley-accumulation-buffer-sig90.pdf

Realistic depth of field effects with OpenGL  http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.74.9692&rep=rep1&type=pdf

Realistic depth of field effects with OpenGL  http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.74.9692&rep=rep1&type=pdf

JH Labs Java Image Processing http://www.jhlabs.com/ip/blurring.html