Wednesday 4 June 2008

Technical: Depth of Field

To help me in my understading of cameras, how to use them and how they work in Maya, i have experimented with Depth of Field. Depth of field is something that we take for granted every day as our eyes automatically adjust to light and distance. Duplicating this effect - where objects are blurred depending on where the cameras focus is - is something i thought would be very useful in any groups films. It would add a more realistic camera shot and, depending on the strength of the blur, prehaps even give the audience the impression they are looking through the eyes of a character or passer by in the films themselves.

Depth of field can be achieved numerous ways. I have experimented with two techniques with two programs i am familiar with: After Effects and maya.

After Effects
In after effects it is possible to create depth of field through the use of a Luminance depth (LD) render from Maya. This is an effect created from the preset menu of the render layers in Maya. LD appears similar to the occlusion render pass in that the whole scene becomes black. The only difference is that the LD layer will gradually fade from black to white. This colour change is key to the work done in after effects.

By importing the render layers into after effects and placing the LD sequence on top the scene should look very much like a test LD render shot. From this point figuring out where on the canvas you want to focus the 'camera' is raltively easy. By hovering the mouse cursor over any area of the canvas it is possible to check the top right hand menu for information on what colour values are present at the cursor location. These also act as a map for the blur. Adding the chosen value to the blur focal distance attribute of the Lens blur effect sets the pinpoint focus of the AE 'camera'. Anything outside the radius of this point will gradually blur. To remain in focus the cursor point must be keyed like any other effect. The three following examples show a character running into focus, out of focus and remain in focus using this method.

Character Focus Video


Near Focus Video


Far Focus Video


This technique provides an excellent, smooth blur over a great distance. This can easily be modified to change the blur radius.

Maya
it is possible to create depth of field (DOF) in Maya using a simple camera and aim. By using the distance measurement tool and constraining (point contrain) locators to both the camera and the aim a camera that can judge the distance between it and its focus has already been created. This takes less than 2 minutes and no rendering is required. Constraining the locators to the camera and aim can be done in the outliner menu by control clicking both the desired child and parent nodes and constraining through the constrain menu. The final phase of this process takes place in the connection editor where (once the distanceDimensionShape1 node has been selected) the left column 'distance' must be selected and in the right column 'Focal distance' (not length!!).

Focus
Out of focus

To turn on DOF selecting the camera1Shape node and entering the attribute editor will unlock the DOF menu. Simply tick the box and voila! The video below uses the same footage as the AE tests however it has all been created and rendered through maya - not composited in AE.

Character Focus Video


This technique works well but the further away from the focus the worse the blur. Aspects of this test resemble a cave painting or pastel artwork! There must be a way to reduce the amount of noise and blur within the attribute DOF settings but for the purpose of quick and easy DOF the AE method wins over for the moment. The Maya method also suffers from an incredibly long render time - especially when occlusion is used (150 frames = 4-6 hours).

No comments: