ANR Tools

ANR Depth Prep

Turns any depth map, AI or CG, into one clean, calibrated distance pass that the other ANR depth nodes read, with edges snapped to the plate and flicker removed.

  • Utility
  • Comp & Depth pack
  • 3 inputs
  • 34 controls

Overview

Depth maps arrive in many forms: near white or near black, 0 to 1 or metres, distance or 1/distance, soft at the edges, flickering from frame to frame. Depth Prep sorts that out once. It reads what the numbers mean (Depth Type, or Auto with its decision shown in Status), turns them into distance in scene units, and hands that on.

It is the hub of the ANR depth tools. Connect the plate to Source and any depth map to Depth; then connect this node to the Depth input of ANR Depth Matte, Depth Look or Depth Camera, or of ANR Normals Prep and Normals Light. Those nodes find it through the wire and read its lens, its Near and Far distances and its focus distance, with nothing typed.

Calibrate puts a relative AI map into real units: drag two points onto things whose distance you know and type the distances. Edge Snap pulls the soft edges of AI depth onto the plate's edges, which removes the halos in defocus and fog, and Deflicker steadies AI depth against the neighbouring frames.

Output can also show the depth as Nuke's 1/distance, a normalized pass, camera-space position or normals, or a false-colour heat map for checking. The Focus section reads the distance under a point and pastes a ready ZDefocus.

Inputs

SourceDepthMotionDepth PrepOutput
  1. Sourceoptional

    The plate. Edge Snap and Deflicker use it to see where edges and motion are; without it the depth is still converted, but Edge Snap is off.

  2. Depthrequired

    Any depth map in its red channel (or the channel set by Depth Channel): ANR Depth and Normal Creator with Write To on RGB, ANR Scene Solver, other AI depth, or a CG render's depth shuffled into rgba.

  3. Motionoptional

    Motion vectors in rgba (forward u v, backward u v), for example ANR AI Vector Tracker with Output on Motion Vectors. Deflicker then follows each pixel to where it moved on moving shots.

Output. With Output on Depth (the default), the distance in scene units in RGB: what the other ANR depth nodes want. The other Output choices are for checking or for other tools.

Quick start

  1. Connect the plate to Source and the depth map to Depth.
  2. From ANR Depth and Normal Creator: set its Write To to RGB (alpha passes through) and Output to Distance (metres), then set Depth Type here to Distance (Z).
  3. For any other map, press Detect and Lock and read Status: it says how it reads the depth and the distances this frame runs to. Pick Depth Type yourself if that is wrong.
  4. For relative AI depth, open Calibrate: drag Point 1 (and Point 2) in the viewer onto things whose distance you know, type Distance 1 (and Distance 2), and press Calibrate.
  5. Set Output to False Colour to check the depth by eye, then back to Depth.
  6. In Lens, type the shot's Focal Length and Horizontal Aperture if you know them; the downstream nodes use them.
  7. Connect this node to the Depth input of ANR Depth Matte, Depth Look or Depth Camera, with the plate on their Source.

The panel

The node's panel as Nuke shows it, with the values of a new node. Click any control to see what it does; tabs and sections work as in Nuke.

ANR_Depth_Prep1
StatusConnect a depth map to the Depth input and the plate to Source, then press Detect and Lock (or pick a Depth Type your...
OutputDepth
Invert Input Depth
Depth TypeAuto
Detect and Lock
Depth ChannelRed
Input Black0
Input White1
Distance Along Ray
Near Distance1
Far Distance50
Distance Scale1
Max Distance10000
Point 1x716.8y466.8
Distance 10
Point 2x1331.2y933.6
Distance 20
Calibrate
Edge Snap0.7
Snap Radius12
Snap Colour Match0.1
Deflicker0
Deflicker Frames2
Motion Tolerance0.08
Focal Length35
Horizontal Aperture36
Normals Smoothing2
PaletteTurbo
Contour Every0
Opacity1
Focus Pointx1024y778
Focus Distance0
Create ZDefocus
Create depth.Z Copy

All controls

ANR Depth Prep34 controls
StatusStatusstatus

What this node reads the depth as, and the distances it comes to.

OutputMenudpOutput

Depth: distance in scene units in rgb -- what the other ANR depth nodes want on their Depth input.
Normalised Depth: 0..1, near white, Near to Far.
Inverse Depth: 1/distance, Nuke's own depth.Z convention (ScanlineRender, ZDefocus 'far = 0').
Position: camera-space X, Y, Z (Nuke axes; Z is negative in front).
Normals: camera-space surface normals, -1..1, facing the camera is +Z.
False Colour: a heat map of the depth to check it by eye.

Default: DepthOptions: Depth Normalised Depth Inverse Depth Position Normals False Colour

Input

Invert Input DepthCheckboxdpInvertInput

Flip the incoming map before conversion and cleanup: Input Black + Input White - depth. For a 0..1 map this is 1 - depth. For other ranges set Input Black and Input White. This overrides the direction inferred by Auto / Detect and Lock. For metric Z versus 1/Z, choose the appropriate Depth Type instead.

Default: off

Depth TypeMenudpType

What the numbers on the Depth input mean.
Auto: looks at the frame and says what it decided in Status.
Distance: real distances (ANR Scene Solver, CG Z-depth).
Inverse Distance: 1/Z (Nuke ScanlineRender depth.Z).
Relative, near bright (disparity): Depth Anything, MiDaS, most AI depth.
Relative, near dark: ANR Depth and Normals (Lotus), Marigold.
Relative, near bright (linear): grey depth maps from other apps.

Default: AutoOptions: Auto Distance (Z) Inverse Distance (1/Z) Relative, near bright (disparity) Relative, near dark Relative, near bright (linear)

Detect and LockButtondpDetect

Decide Depth Type from this frame and fix it, so it cannot change between frames. Also reads the input range from a raw, unnormalised map.

Depth ChannelMenudpChannel

Which channel of the Depth input holds the depth.

Default: RedOptions: Red Green Blue Alpha Luminance

Input BlackSliderdpInLo

Relative types: the raw value that means the Far end (near-bright maps) or the Near end (near-dark maps). 0 for a normalised map.

Default: 0

Input WhiteSliderdpInHi

Relative types: the raw value at the other end. 1 for a normalised map.

Default: 1

Distance Along RayCheckboxdpRay

Distance and Inverse types: the depth measures along each pixel's ray rather than straight down the lens axis. Most renders and the Scene Solver are straight down the axis (off).

Default: off

Distances

Near DistanceSliderdpNear

Relative types: the distance the nearest value means. Also the near end of Normalised Depth and False Colour. Calibrate sets it for you.

Default: 1

Far DistanceSliderdpFar

Relative types: the distance the farthest value means. Also the far end of Normalised Depth and False Colour.

Default: 50

Distance ScaleSliderdpScale

Distance and Inverse types: multiply into scene units (0.01 turns centimetres into metres). Calibrate sets it for you.

Default: 1

Max DistanceSliderdpMaxDist

Nothing is farther than this: sky, empty background, infinity.

Default: 10000

Calibrate

Point 1PositiondpCalPoint1

Drag onto something whose distance you know (a person, a door, the ground at a known spot).

Default: 716.8 466.8

Distance 1SliderdpCalDist1

How far Point 1 is from the camera, in your units (metres, say).

Default: 0

Point 2PositiondpCalPoint2

Drag onto something whose distance you know (a person, a door, the ground at a known spot).

Default: 1331.2 933.6

Distance 2SliderdpCalDist2

How far Point 2 is. Leave 0 to calibrate from Point 1 alone (scale only).

Default: 0

CalibrateButtondpCalibrate

Solve the distances so the two points read what you typed. Sets Near/Far (relative types) or Distance Scale (distance types).

Clean Up

Edge SnapSliderdpSnap

Pull the depth's edges onto the plate's edges. AI depth is soft and a few pixels off at outlines, which is what makes halos in defocus and fog. Needs the plate on Source. Set it to 0 for a CG render's depth, which is already exact (at 0.7 it moves exact depth by 0.2% on average).

Default: 0.7

Snap RadiusSliderdpSnapRadius

How far, in pixels, an edge may be pulled.

Default: 12

Snap Colour MatchSliderdpSnapEdge

How alike two plate colours must be to count as the same surface. Lower splits on fainter edges (and on texture); higher only on strong ones.

Default: 0.1

DeflickerSliderdpFlicker

Steady per-frame AI depth against its neighbours: the whole frame's level first, then patches. 0 is off. Wire vectors to Motion for moving shots.

Default: 0

Deflicker FramesSliderdpFlickerFrames

Frames each side to compare against.

Default: 2

Motion ToleranceSliderdpFlickerSigma

How different the plate may look at a pixel before a neighbouring frame stops counting there (it has moved). Lower is safer on moving shots.

Default: 0.08

Lens

Focal LengthSliderdpFocal

Millimetres. Used for Position and Normals here, and read by the Look and Camera nodes. Copy it from a solved camera if you have one.

Default: 35

Horizontal ApertureSliderdpAperture

Film back width in millimetres (36 = full frame, 24.9 = Super 35).

Default: 36

Normals SmoothingSliderdpNormalSmooth

Pixels of smoothing on the Normals output. Depth maps are noisy in their slopes.

Default: 2

False Colour

PaletteMenudpPalette

Colours for Output = False Colour, near to far across Near/Far Distance.

Default: TurboOptions: Turbo Inferno Magma Viridis Thermal Ice Neon Spectrum Night Vision Grey

Contour EverySliderdpContour

Draw a line every this many units of distance. 0 is off.

Default: 0

OpacitySliderdpOverPlate

False colour over the plate: 1 is solid colour.

Default: 1

Focus

Focus PointPositiondpFocusPoint

Drag onto what should be sharp. Focus Distance reads the depth there.

Default: 1024 778

Focus DistanceSliderdpFocusDist

The distance at the Focus Point (set when you move it; type over it freely). Create ZDefocus puts it into the ZDefocus's focal plane.

Default: 0

Create ZDefocusButtondpMakeZDefocus

Put a Copy (this node's depth into depth.Z on the plate) and a ZDefocus focused at Focus Distance on the clipboard. Ctrl+V in the Node Graph.

The pasted ZDefocus reads distance directly, so keep Output on Depth. If Status asks you to, paste with the plate selected and connect the Copy's A input to this node.

Create depth.Z CopyButtondpMakeDepthLayer

Just the Copy: the plate with this node's distance in depth.Z, for any Nuke tool that reads a depth layer.

The Copy carries this node's distance (not 1/distance) into depth.Z, so keep Output on Depth.

Tips

  • Set Edge Snap to 0 for CG depth, which is already exact; keep it for AI depth.
  • For flickering per-frame AI depth, raise Deflicker toward 1. On moving shots, connect motion vectors to Motion, and lower Motion Tolerance if moving parts smear.
  • Contour Every draws a line every so many units on the False Colour view, a quick way to check that distances grow evenly.
  • Drag Focus Point onto what should be sharp: Focus Distance reads the depth there. Create ZDefocus then puts a Copy and a ZDefocus focused at that distance on the clipboard; press Ctrl+V in the Node Graph.
  • ANR Depth Camera uses this node's Focus Distance as its default for Keep Size At and Convergence.
  • The downstream nodes find this node by following their Depth input upstream, so a Reformat or a Grade in between is fine.
  • A Nuke ScanlineRender writes 1/distance into depth.Z: Shuffle it into red and set Depth Type to Inverse Distance (1/Z).

Good to know

  • The node runs no AI model and needs no graphics card.
  • It reads only the red, green, blue and alpha channels of the Depth input, never a depth.Z layer directly.
  • A depth map more than about 10% smaller or larger than the plate is stretched over the plate (a low-resolution AI map); within that, it is laid pixel for pixel. Crop or Reformat a CG depth whose bounding box differs from the plate first.
  • Relative AI depth is not in real units until you calibrate it. Fog density, occlusion radius, shadow length and camera moves downstream are all in this node's units.
  • Deflicker reads several frames for each frame it renders, so it slows the node down.

Something unclear or missing? Write to [email protected].