Camera¶
Gaffer’s cameras setups are quite flexible, allowing for a variety of camera types, measurement systems, and industry-standard formats. With this freedom, you can simulate many common camera and lens setups.
In this article, we will assume you are fairly familiar with camera terminology and the settings of real cameras and lenses.
Before you begin, we highly recommend you read Anatomy of a Camera.
Camera basics¶
Each Camera node (Scene > Source > Camera) adds a scene containing a single location (/camera
by default) with a camera object. When previewing the scene in the Viewer, the camera object is represented by a wireframe model. The width and size of the frustum on the model roughly corresponds to the angle of view and aspect ratio of the camera.
Scenes can support multiple cameras, but renderers typically work with one at a time. The StandardOptions node, placed downstream, sets which camera in the scene to use for a given render.
When looking through a camera, the Viewer matches its projection, so the scene will appear as foreshortened or as flat as dictated by the projection parameters. This lets you preview the precise framing and composition of the scene. Additionally, a frame overlay appears in the Viewer, showing the aperture gate, the resolution gate, and the crop window.
Tip
If the aperture gate isn’t visible, that means it is identical to the resolution gate.
Instructions¶
Manipulating a camera¶
Selecting, translating, and rotating a camera¶
Like other objects in the scene, the camera can be manipulated in the Viewer. You can select it by clicking it or dragging a marquee around it, rotate it with the Rotate Tool (W), and translate it with the Translate Tool (E).
Selecting a look-through camera for a Viewer¶
Each Viewer can be set to look through a camera in the scene, rather than the default free camera. This can be quite useful if the scene has multiple cameras and you need to preview each in a separate Viewer at once, such as in a scene with witness cameras, or if you simply want to compare the flat-shaded scene to its render preview.
To select a look-through camera for a Viewer:
- In the Viewer, click . A drop-down menu of objects will appear.
- Select either Render Camera for the current scene’s render camera (if defined by a StandardOptions node), or a camera from the Camera sub-menu (a list of all cameras in the current scene).
Translating and rotating the look-through camera¶
With the Camera Tool toggled on, you can translate and rotate the look-through camera with the camera controls.
Note
The shortcuts for the clipping plane affect the clipping plane of the default free camera, not the look-through camera.
Orbiting with the look-through camera¶
Like the default free camera, you can set the look-through camera to focus on an object in the scene, and orbit it around that object’s position.
To orbit with the look-through camera:
- Make sure the Camera Tool (T) is activated.
- Select an object in the scene.
- Hit F. The camera will aim at the object and adjust position.
- Use the camera controls to orbit around the object.
Constructing a perspective camera¶
When constructing a camera with perspective projection, there are two projection modes available: Field Of View, and Aperture and Focal Length. With Field Of View, you can provide an angle of view, like with a typical CG camera. With Aperture and Focal Length, you can replicate the real projection settings of a camera/lens setup by inputting its actual aperture and focal length settings.
To construct a perspective camera:
- Create a Camera node (Scene > Source > Camera).
- In the Node Editor, set the Projection plug to Perspective.
Then, assign the projection parameters using one of the perspective modes:
Using field of view¶
- Set the Perspective Mode plug to Field Of View.
- Input an angle for the Field Of View plug, in degrees.
- For the Aperture Aspect Ratio plug, input an appropriate horizontal-to-vertical ratio for the image. For example, a 16:9 frame would be
1.778
.
Using aperture and focal length¶
- Set the Perspective Mode plug to Aperture and Focal Length.
- For the Aperture plug, select the appropriate camera from the list of standard camera film backs/sensors. If the camera you need is not available:
- Select Custom. Two new plug fields will appear. Fill in:
- aperture.x: The horizontal film back/sensor length, typically in millimeters.
- aperture.y: The vertical film back/sensor length, typically in millimeters.
- Set the Focal Length plug to an appropriate lens focal length. This is typically in millimeters.
- Select Custom. Two new plug fields will appear. Fill in:
Important
You can set Aperture and Focal Length as numbers in any unit of measure (millimeter, centimeter, inch, etc.), so long as they use the same unit of measure, and the lengths are proportional to each other. For example, if the film back is in millimeters, then the focal length should also be in millimeters.
Offsetting a camera¶
The offset is the amount by which the camera view is shifted parallel to the image plane. This parameter is used in special cases, such as simulating a tilt-shift lens, rendering tiles for a panorama, or matching a plate that has been asymmetrically cropped.
A camera’s Aperture Offset plug controls the horizontal and vertical offset. The length of one unit of offset depends on the projection type of the camera:
- Perspective projection:
- Field Of View mode: 1 offset = 1 whole horizontal field of view (for example, 45°).
- Aperture and Focal Length mode: 1 offset = 1 aperture unit of measure (for example, 1 millimeter).
- Orthographic projection: 1 offset = 1 world space unit.
Adding depth of field blur¶
Depth of field is controlled as if the camera had a lens, with plugs analogous to real lens settings – F Stop and Focus Distance. You can use these settings to replicate the depth of field of a real lens.
Tip
If you need to preview depth of field blur, render the scene through an interactive renderer.
To add depth of field blur:
- Select the Camera node in the Graph Editor.
- In the Node Editor, switch to the Depth of Field tab.
- Input an appropriate F Stop for the lens aperture. The higher the number, the less depth of field blur.
- Select a Focal Length World Scale. This is the scale factor between the camera’s focal length unit of measure and the world space unit of measure. For example, if the focal length is measured in millimeters but the world is measured in centimeters, select Millimeters to Centimeters (0.1). For most scenes and scene formats, use this scale. If the scale you need isn’t provided, select Custom and input a custom scale.
- Input the Focus Distance between the camera and the object(s) in focus, in world space units.
- On a downstream StandardOptions node, enable the Depth Of Field plug (click ) and turn it on.
Important
Depth of field information will only be passed to the renderer if the Camera node’s F Stop plug is greater than 0
and a downstream StandardOptions node has its Depth of Field Blur plug enabled and turned on. Otherwise, your render will not have depth of field blur.
Render overrides and camera tweaks¶
Depending on your workflow and pipeline process, and how upstream data is inherited by your graph (such as from Reference nodes), you may find yourself in situations where you need to:
- Introduce a camera that, to work correctly, must override one or more of the scene’s render options (such as the film fit), preempting the downstream StandardOptions node.
- Override an upstream camera’s parameters, or preempt the downstream render options, without modifying the associated nodes.
- Completely override a camera to create a custom camera type.
You can resolve these by enabling the Camera node’s render overrides, employing a CameraTweaks node, or a combination of both.
Render overrides¶
A render override is a special camera parameter that overrides a corresponding render option.
Since an override is a parameter, and thus data on the camera’s object, it does not modify the actual render option. It instead takes precedence over the render option during computation or rendering. An override can be tweaked or removed at a later point in the graph. If removed, the corresponding render option will come into effect again.
To activate a render override:
- Select a Camera node in the Graph Editor.
- In the Node Editor, switch to the Render Overrides tab.
- Enable the override (click ) and adjust its plug values as needed.
Camera tweaks¶
The CameraTweaks node (Scene > Object > Camera Tweaks) is a special node that adds any number of adjustments, known as as camera tweaks, to render options and camera parameters. A camera tweak can also add custom camera parameters to the scene data.
Multiple tweaks can be applied to the same parameter or render option. If so, they apply their operations in sequence.
Every tweak from the CameraTweaks node is applied to every camera specified by the node’s filter.
To add a camera tweak:
- Create a CameraTweaks node at a point in the graph that is downstream of the target camera(s).
- Create a PathFilter node, add the path location(s) of the camera(s) to it, and connect it to the filter plug of the CameraTweaks node.
- Select the CameraTweaks node.
- In the Node Editor, click and select a parameter or render option to tweak. The tweak will appear in the editor as a compound plug.
- Enable the tweak (click ).
- Assign the tweak operation:
- Mode: The operation to apply between the new value and old value of the parameter or render option. You have a choice between Replace, Add, Multiply, and Remove. String values cannot be multiplied/added/subtracted. For example, with default parameter value
A
, operation Multiply, and new valueB
, the tweak would applyA × B
. - Value: The new value to use in the operation.
- Mode: The operation to apply between the new value and old value of the parameter or render option. You have a choice between Replace, Add, Multiply, and Remove. String values cannot be multiplied/added/subtracted. For example, with default parameter value
Example graphs¶
Anamorphic camera setup¶
This can be loaded in Gaffer from Help > Examples > Rendering > Anamorphic Cameras.
A setup that replicates an anamorphic camera and lens, by rendering with a non-square pixel aspect ratio.
Spherical camera in Arnold¶
This can be loaded in Gaffer from Help > Examples > Rendering > Spherical Cameras (Arnold).
A camera with spherical projection that is compatible with the Arnold renderer. To achieve this, a CameraTweaks node overrides certain camera parameters to create a custom projection type. The tweaks are:
Tip
Other renderers will likely use similar means to achieve spherical cameras.
Note
Due to a bug, when rendering a spherical camera for Arnold, the filmFit
tweak must be set to Horizontal, not Distort.