DepthGenerator

The DepthGenerator node (NukeX and Nuke Studio only) allows you to generate a depth map from your footage. The node uses information from a tracked camera to create a channel that displays variations in depth.

A depth map is an image that uses the brightness of each pixel to specify the distance between the 3D scene point and the virtual camera used to capture the scene.

DepthGenerator also allows you to output depth as normals and position passes, and create a Card3D node positioned in 3D space and displaced according to the depth channel.

Inputs and Controls

Connection Type

Connection Name

Function

Input

Mask

The mask used to ignore areas of the source image. DepthGenerator expects alpha values of either 0 (for regions to use) or 1 (for regions to ignore).

Depth can only be calculated where the real world 3D position of objects doesn’t change. If there are moving objects in your Source footage, DepthGenerator is likely to struggle to create an accurate depth map for those regions. To prevent this, you can exclude moving foreground regions from the depth calculation by connecting a matte to this input and setting Ignore Mask in the DepthGenerator properties to the channel that contains the matte.

The Mask input only appears once you’ve connected the other two inputs.

Camera

A tracked Camera that matches the Source footage. If necessary, you can create one using the CameraTracker node.

Source

The source footage from which the Camera track was derived.

Control (UI)

Knob (Scripting)

Default Value

Function

DepthGenerator Tab

Ignore Mask

ignoreMask

None

Sets the mask type to exclude areas of the Source footage during depth calculation. DepthGenerator expects values of either 0 (for regions to use) or 1 (for regions to ignore).

Depth can only be calculated where the real world 3D position does not change. If your Source footage includes moving foreground objects, it’s a good idea to supply a mask to prevent distortion in moving regions:

None - none of the footage is ignored.

Source Alpha - use the alpha channel of the Source clip to define which areas to ignore.

Source Inverted Alpha - use the inverted alpha channel of the Source clip to define which areas to ignore.

Mask Luminance - use the luminance of the Mask input to define which areas to ignore.

Mask Inverted Luminance - use the inverted luminance of the Mask input to define which areas to ignore.

Mask Alpha - use the Mask input alpha channel to define which areas to ignore.

Mask Inverted Alpha - use the inverted Mask input alpha channel to define which areas to ignore.

Alternatively, you can try using a smaller Frame Separation to capture moving objects.

Output

Depth Output

outputType

Depth (1/Z)

Sets the type of output produced:

Depth 1/Z - output 1/Z where Z is the distance along the camera Z axis. This matches the depth output of the ScanlineRender node.

Distance - output the distance along the ray from the camera center to the 3D surface point.

Create Card

createCard

N/A

Click to create a group containing a displaced Card to visualize depth as a surface in 3D space.

Note:  The DepthOutput control must be set to Depth (1/Z).

Surface Point

P_channel

none

Sets the channel(s) to output depth as a position pass.

The position pass includes the X, Y, and Z coordinates for each pixel in the image. You can use it with the Relight node, or with the PositionToPoints node to visualize depth as a 3D point cloud.

Surface Normal

N_channel

none

Sets the channel(s) to output depth as a normals pass. Use the NormalDetail control to affect the smoothness of the normals pass.

The normals pass contains three vectors of information for each pixel in the image: X direction, Y direction, and Z direction. In other words, it stores the direction in which each point in the image is facing. You can use a normals pass with the Relight node.

Frame Separation

Analyze Sequence

analyzeSequence

N/A

Click to automatically calculate the FrameSeparation to use in the sequence.

For this to work, the camera in the Camera input must be defined for all frames within the frame range.

Note:  If you analyze the sequence and only then decide to add an ignore mask, you should analyze the sequence again after adding the mask.

Analyze Frame

analyzeFrame

N/A

Click to calculate the Frame Separation to use at the playhead frame.

This gives you more control than Analyze Sequence, as you can work through the timeline, analyze particular frames, and if necessary tweak the Frame Separation value manually.

The camera in the Camera input must be defined for all frames within the frame range.

Frame Separation

frameSeparation

1

Adjusts the offset between the current frame and the frame against which to calculate depth for your input.

Use a small separation value for fast camera moves and a larger value for slow camera moves.

Increasing the separation gives a larger baseline and more accurate depth. However, a high separation reduces the quality of image matching and gives incorrect 3D points.

Animate the FrameSeparation to compensate for variable camera speeds.

The camera in the Camera input must be defined for all frames within the frame range.

Note:  The Analyse Sequence and Analyse Frame buttons attempt to calculate the best separation.

Calculated Accuracy

accuracy

N/A

Displays the depth accuracy calculated when analyzing frame separation. Values closer to 1 are considered accurate, and values closer to 0 inaccurate.

Use frames with a high accuracy when placing elements in 3D (for example, by clicking Create Card or using a PositionToPoints node).

If you’re not getting accurate depth values, try adjusting Frame Separation or using an Ignore Mask.

Depth Generation

Depth Detail

vectorDetail

0.5

Adjust this to vary the resolution of the images used to calculate the depth map. The default value of 0.5 equals half the image resolution. Lower values speed up processing and deliver a smoother result. Higher values pick up finer details, but also increase processing time.

Normal Detail

normalDetail

0.25

Adjusts the resolution of the surface normals. Reduce the detail to smooth out the normals pass.

The default value of 0.25 causes the normals pass to be calculated at a quarter resolution.

Noise

noiseLevel

0.01

Sets the amount of noise to ignore in the input footage when calculating the depth map.

Try increasing this to smooth depth in flat image regions.

Strength

strength

1

Sets the strength in matching pixels between frames. Increase this to force the matches, for example where fine details are missed, or reduce to smooth depth.

In most cases, you can leave this at the default value.

Sharpness

sharpness

0.5

Defines how distinct object boundaries should be. Increase sharpness to separate objects and reduce it to smooth depth.

Smoothness

smoothness

0.5

Adjusts the smoothness weighting of the disparity calculation. Rather than affecting the depth calculation, this applies an intelligent blur on the result.

A high smoothness can miss lots of local detail, but is less likely to produce noisy depth values. A low smoothness will concentrate on detail matching, even if the resulting depth map is jagged.

Depth Limits

Near Clip Plane

near

0.1

Sets the minimum z depth. All depth values that are lower than this number are set to this value.

Far Clip Plane

far

10000

Sets the maximum z depth. All depth values that are higher than this number are set to this value.

Mark Bad Regions

markRegions

disabled

When enabled, the regions where the depth calculation is ambiguous are marked in the depth map as very large values.

Step-by-Step Guides

Generating Depth Maps

Video Tutorials

NUKE 7.0 - DepthGenerator from Foundry on Vimeo.