| reference
materialDepth of Field Control Using Two Nulls |
| |
| by Joshua Albers |
|
| April 28th, 2004 |
|
| |
| Introduction; |
|
This tutorial will show you how to easily set up and control depth of field for your LightWave scenes using parented null objects, the Depth-Of-Field custom object, and the Channel Follower modifier.
Depth of field is defined by two values: Focal Distance and Lens F-Stop. Focal Distance defines the distance away from the camera that will be in focus, and Lens F-Stop defines how far in front of and behind the Focal Distance the area of focus will extend. Larger Lens F-Stop values increase the depth of field, allowing many objects to be in focus. This is called "deep focus". Smaller Lens F-Stop values decrease the depth of field, thus restricing the area that will be in focus. This is called "shallow focus".
By default, the Focal Distance and Lens F-Stop settings are controlled through the Camera Properties panel or the Graph Editor in Layout; however, it is possible to control the depth of field settings using some of the many tools and modifiers that are included with LightWave 7.5
It is entirely possible to use depth of field without also using the technique described below, but the "parented nulls" technique allows the depth of field settings to be directly animated through the Timeline rather than forcing the user (you) to go through the Graph Editor.
|
| |
| Before you begin: |
| |
- This technique uses null objects that are parented to the camera to
control depth-of-field settings. The null objects must be properly aligned
to the camera's coordinates, or else the display and control settings
will not work. In order for the null's initial position and alignment
to be set correctly when parented to the camera, Parent in Place must
be turned off in the General Options panel ("o").
- The Grid Size value in the Display Options panel ("d") needs
to be adusted to properly fit the objects in your scene file. If your
Grid Size is set too large, your cameras, lights, and nulls will appear
to be much larger than your objects and it will be very hard to make
small adjustments to object positions. If your Grid Size is too small,
your camera, lights, and nulls will be very hard to see and you will
have to move the mouse more to make small adjustments. Layout automatically
sets the grid size when you load objects into a scene; if you add a
very large object (such as a ground plane), Layout will set the Grid
Size to a very high value, which will make it harder for you to select
and manipulate the objects in your scene. The optimal Grid Size value
depends on the scale of your objects; ideally, the camera and Nulls
should be easily visible but not too large.
|
| |
| Enabling depth of field
for a camera: |
| |
|
Before we can set up nulls to control our depth of field settings, first we need to enable depth of field. The Focal Distance and Lens F-Stop settings are not accessible until depth of field is enabled in the Camera Properties panel ("p").
|
| |
| 
- Open the Camera Properties panel ("p") for the camera to
which you would like to add depth of field.
- Set Antialiasing to Medium or higher; depth of field is unavailable otherwise
(and even if it was available at antialiasing levels lower than Medium,
it would look very bad).
- Under the tab labelled "Stereo and DOF", enable the Depth
of Field checkbox. Depth of Field is now enabled and can be manipulated
by changing the Focal Distance and Lens F-Stop values under the Stereo
and DOF tab in the Camera Properties Panel.
|
| |
- In LightWave 7.5, it is possible to preview depth of field and motion blur in the
OpenGL window in Layout. To use the OpenGL preview, first set one of
your viewports to Camera View. Then, move the mouse cursor over the camera
viewport, and press SHIFT + F9. Remember, in order to use the OpenGL
preview for Depth of Field and/or Motion Blur, they must be enabled
in the Camera Properties panel ("p").
|
| |
| Setting a null object
to display depth of field settings in Layout: |
| |
|
One of the more useful tools in LightWave is the Depth-Of-Field custom object. The Depth-Of-Field custom object creates a wireframe object in the OpenGL viewports in Layout that roughly shows what will be in focus with the current depth of field settings. In order to apply it, all you have to do is parent a null object to the camera, and then add the Depth-Of-Field custom object to the null.
|
| |
| 
- Add a null object to the scene (Items > Add > Objects >
Add Null...).
|
- Be sure to give the null a name that easily identifies it as the depth
of field display object. For example, you could name the null DOF_Display
(that's what I did).
|
| |
- DO NOT move, scale, or rotate the null! Otherwise it won't be lined
up properly when you parent it to the camera! It is a good idea to disable
all the movement, rotation, and scale axes (axes = plural of axis) in
the lower right hand corner of Layout. Disabling the axes will prevent
you from accidentally moving the null.
|
| |
- Open the Motion Properties panel ("m") for DOF_Display.
and parent DOF_Display to the camera. (Make sure Parent In Place is off!).
If you made sure that DOF_Display was centered at the origin (as per
the previous step), DOF_Display should snap to the camera's position
and alignment.
|
| |
- Open the Object Properties panel ("p") for DOF_Display.
- In the Geometry tab, add the Depth-Of-Field Display custom object
through the Add Custom Object dropdown box (Geometry > Add Custom
Object > Depth-Of-Field Display). When you add the Depth-Of-Field
custom object, it will be added to the custom object list as "DOF
Circle of confusion 3.125e-005 m" or something similar.
- In almost all situations, the default settings for the Depth-Of-Field
custom object will be acceptable. I have yet to encounter a situation
where I needed to change the settings.
|
| |
- The Depth-Of-Field custom object creates a wireframe object in Layout
that roughly shows what will be in focus. The wireframe will not render;
it is only visible through the OpenGL viewports in Layout.
- Combined with the OpenGL Depth of Field and Motion Blur preview capability,
the Depth-Of-Field custom object makes setting up and animating depth
of field much, much simpler by taking out the guesswork and
manual measurement; with the Depth-Of-Field custom object and the OpenGL
preview, you can just manipulate the Focal Distance and Lens F-Stop
values in the Camera Properties panel until you get the results you
want.
|
| |
| Setting a null object to control Focal Distance: |
| |
|
Now we have to set up a new null object to use as the control object. First we add the null, then we parent it to the object, and then we link the null's Z position to the camera's Focal Distance.
|
| |
- Add a null object to the scene (Items > Add > Objects > Add Null...)
|
| |
- Name the null something that clearly identifies it as the control object; for example, you could name it DOF_Control.
|
| |

- Make certain that you do not move, rotate, or scale DOF_Control at
all! Any pre-exising coordinate values for DOF_Control will be carried
over when you parent it to the camera, and that will effectively break this
whole method of controlling depth of field with a null.
- In order for you to effectively control both the Focal Distance and
Lens F-Stop values using only DOF_Control, it needs to be constrained
on all but two axes: Position Z and Scale Z. Disable Position X, Y;
Rotation H,P,B, and Scale X, Y in the lower right-hand corner of Layout.
|
| |
- Open the Motion Properties panel ("m") for DOF_Control and
parent it to the camera (Make sure Parent In Place is off!).
|
| |
- Open the Camera Properties panel ("p") for the camera that you're using.
- Under the Stereo and DOF tab, set Focal Distance to be controlled
by an envelope (click the button marked E next to Focal Distance). Setting
Focal Distance to be controlled by an envelope places the channel in
the Graph Editor, thereby allowing you to set keyframes for its value
(i.e., animate Focal Distance). It also prevents you from changing the
Focal Distance from the Camera Properties panel.
|
| |
- When you clicked the "E" button, the graph editor should
pop up with Camera.FocalDistance as the only channel enabled (if the Graph
Editor was already open, you will have to manually select the Camera.FocalDistance
from the channel list).
- Under the Curves tab in the Graph Editor, set the value for the first
keyframe for Camera.FocalDistance to 0 m and delete all other keyframes
for Camera.FocalDistance. Any keyframe values for Camera.FocalDistance
will be added to the value set by DOF_Control, thus causing the Focal
Distance value to be set improperly.
|
| |
- Under the Modifiers tab of the Graph Editor, add the Channel Follower modifier to Camera.FocalDistance.
|
| |

- The Channel Follower modifier uses a channel from another object (anything
that can be animated in the Graph Editor) and adds it to the current
channel. What we want to do is get the value for Camera.FocalDistance
from DOF_Control.Position.Z.
- Double click Channel Follower in the Modifier List to bring up the
Channel Follower panel.
- In the Channels list, select DOF_Control > Position.Z. Press OK.
|
| |
- Now the Z position of DOF_Control controls the Focal Distance of the
the camera. That means that when you move DOF_Control along the Z axis,
it essentially measures the distance between itself and the camera and uses
that value for the Focal Distance.
- By parenting it DOF_Control to the camera, and enabling only the Z position
axis for DOF_Control, it now acts like a tape measure from the camera to the intended focal distance.
- In order for the DOF Display box to be interactively affected by
the position of DOF_Control, Auto Key must be turned on.
|
| |
| Setting a null object to control Lens F-Stop: |
| |
|
Now that our null is configured to act like a tape measure that controls the camera's Focal Distance, we want to set it to control the camera's Lens F-Stop. All we have to do is link the null's Z scale value to the camera's Lens F-Stop.
|
| |
- Open the Camera Properties panel ("p") for the camera that you're using.
- Under the Stereo and DOF tab, set Lens F-Stop to be controlled by
an envelope (click the button marked E next to Lens F-Stop). Setting
Lens F-Stop to be controlled by an envelope places the channel in
the Graph Editor, thereby allowing you to set keyframes for its value
(i.e., animate Lens F-Stop). It also prevents you from changing the
Lens F-Stop value from the Camera Properties panel.
|
| |
- When you clicked the "E" button, the graph editor should
pop up with Camera.FStop the only channel enabled (if the Graph
Editor was already open, you will have to manually select the Camera.FStop
from the channel list).
- Under the Curves tab in the Graph Editor, set the value for the first
keyframe for Camera.FStop to 0 m and delete all other keyframes
for Camera.FStop. Any keyframe values for Camera.FStop
will be added to the value set by DOF_Control, thus causing the Lens F-Stop value to be set improperly.
|
| |
- Under the Modifiers tab of the Graph Editor, add the Channel Follower modifier to Camera.FStop.
|
| |
- The Channel Follower modifier uses a channel from another object (anything
that can be animated in the Graph Editor) and adds it to the current
channel. What we want to do is get the value for Camera.FStop
from DOF_Control.Scale.Z.
- Double click Channel Follower in the Modifier List to bring up the
Channel Follower panel.
- In the Channels list, select DOF_Control > Scale.Z. Press OK.
|
| |
- Now the Z scale value of DOF_Control controls the Lens F-Stop of the camera. That means that when you increase or decrease the Z scale of DOF_Control,
the Lens F-Stop value increases or decreases (i.e. the focal depth gets deeper or more shallow) accordingly.
- Now DOF_Control allows you to control both the Focal Distance and Lens F-Stop directly in the Timeline.
- Just as with the Focal Distance, the Depth-Of-Field display object will not interactively show the changes made to either the Focal Distance or Lens F-Stop values unless Auto Key is turned on.
|
| |
| Summary and Conclusion: |
| |
In this tutorial, we learned how to:
- Enable depth of field for a camera
- Create a Depth-Of-Field custom object to preview depth of field in the OpenGL viewports in Layout
- Preview depth of field in the OpenGL Camera View in Layout
- Control a camera's Focal Distance with a null object's Z position with the Channel Follower modifier
- Control a camera's Lens F-Stop with a null object's Z scale with the Channel Follower modifier
By using the technique described in this tutorial, now we can preview and animate the depth of field settings directly in the Timeline rather than using the Camera Properties and Graph Editor windows.
|
| |
| |
| Back to Reference
Materials |
| |
| Last Modified Date: April 28th, 2004 |
| Last Modified By: Joshua
Albers |