Depth of field

Description

The 'Depth of field' (DOF)-shader is a shader that makes it easier to use softimage's focusing abilities. To focus on an object just define a NULL-object at the place/object you want in focus and select this in the shader!. Can it be easier? Furthermore its very easy to animate! 
 

Tutorial

Load the "DOFTutorial" scene from the DepthOfField-Tut database and render the scene: 
 
 
Now let's put on some focus. 
 
  • At first create a NULL-object and name it "Focus" (Get->Primitive->Null creates the object. Info->Selection, type:"Focus" in the name field and press ok, names it "focus").
  • Place the Focus-object at the text that says "Focus".
  • Add the DepthOfField-shader by selecting it in the camerasettings dialog. (Camera->Settings and press 'Select', browse to the NF-shaders database and select the DepthOfField-shader)
  • Enter the shaderparamters menu by pressing 'Edit'. In the 'Focus plane' section see that the radiobutton 'Defined by point' is pressed (It is by default) and press the 'Select'-button and select the object named "Focus". Now focus is set on the focusobject. The next thing is to set how big an effect the DepthOfField-shader has on the picture. In the 'lens size' section make sure that the 'Defined by diameter'- radiobutton is pressed (it is by default) and set the diameter to 4.0
Now render the picture (remember it has to be done with Mentalray): 
 

(If mentalray gives you the warning:"lens shader runs in scanline mode". You have to switch this off. This is done by changing the line: 

    set SI_MI_TRACER=%SI_LOCATION%\mental_ray\bin\ray.exe 
to 
    set SI_MI_TRACER=%SI_LOCATION%\mental_ray\bin\ray.exe -scanline off 

in your config-file. On SGI-systems this is found in the file .softimage in the user's homedir (jot ~/.softimage) and on NT-systems you just press the Windowsbutton Start->Programs->Softimage->Edit SETENV. 

NB! Reload Softimage to make the changes take effect.) 

Now lets take a look at the picture. The focus effect is there allright but the area that isn't in focus dosn't look good. To take care of this we increase the number of samples of the antialiasing-routine. Enter the render-dialog and press the antialiasing button. Make sure that the 'active'-checkbox is chekked and set 'max samples' to 5. Now render the picture: 
 

 (We could also set the number of samples to 7 and get the picture at the top of this page.) 

Now try out the following things: 

  • Experiment with diffrent values of lens-size and notice that a bigger lens get a bigger effect on the picture and while the effects gets bigger, the number of samples it takes to get a good looking picture increases.
  • Try to animate the focus-object and see how easy it is!
    You can also animate the lenz-size. This is done by pressing the 'Defined by point'-button in the 'lens size' section in the shader-parameters. Press the 'Select button' and select the focus-point. The lenz-size is now defined by the distance from the Focus-point to the line that goes through the camera and the interest of the camera.