Skip to content

Depth Merge ​

Combines two images by depth: at every pixel, whichever one is nearer the camera goes in front. For putting CG elements rendered separately back together with their depth passes.

Category: Composite Menu path: Composite > Depth Merge

Ports ​

PortTypeDirectionDescription
aimageRgba16finputFirst image
bimageRgba16finputSecond image
depthAimageRgba16finputDepth pass for A
depthBimageRgba16finputDepth pass for B
outimageRgba16foutputA and B combined, nearer in front
depthimageRgba16foutputThe nearer depth at each pixel (for chaining another Depth Merge or a Lens Blur)

Parameters ​

ParamTypeDefaultDescription
closerstringSmallerSmaller is closer — lower depth values are nearer the camera (the usual Z-depth pass). Larger is closer — for passes where bigger means nearer (some renderers' inverted or normalized depth).
softnessscalar0Range of depth, in the depth pass's own units, over which the two images blend instead of switching hard. 0 = a hard cut.
depthChannelstringLuminanceWhich channel of the depth images holds the depth: Luminance, Red, Green, Blue or Alpha.

How It Works ​

At every pixel Depth Merge reads A's depth and B's depth and puts the nearer image over the farther one — a normal over composite, so semi-transparent edges and motion blur in the front image still show the back image through them. Where only one image is there (the other is transparent), that one is shown.

An image with no depth pass wired is treated as infinitely far away, so it always goes behind. With neither depth wired the node behaves like a plain A-over-B merge.

softness blends between "A in front" and "B in front" over that much depth, centered on where the two depths are equal — at exactly equal depth you get half of each. Use it to hide aliasing where two surfaces intersect.

The depth output carries the nearer of the two depths (as a gray image, opaque wherever either image has a depth), so you can chain several Depth Merges or feed the combined depth into a LensBlur. With only Depth A and Depth B wired (no images), it still combines the two depth maps into one. Empty sky in a render's depth pass is "infinitely far" and never wins over a real surface. Depth values are real distances, usually far above 1, so the depth output looks mostly white in the Viewer; that's expected.

Usage Examples ​

Basic: Combine two render layers ​

A character and an environment rendered separately, each with its own depth pass:

  1. Character beauty → a, character Z → depthA.
  2. Environment beauty → b, environment Z → depthB.
  3. The character now walks behind and in front of the environment correctly.

Basic: More than two elements ​

Chain Depth Merges: feed the first one's out and depth into the next one's a and depthA, and the next element into b / depthB.

Tips ​

  • The node shows NO DEPTH when neither depth input is connected (it can't tell what's nearer), and NO IMAGES when only the depth inputs are (the Depth output still works; the main output has nothing to show).

  • Depth passes must be linear and unfiltered to merge cleanly — load EXR depth with the color space set to Raw (or Linear) so nothing converts it.

  • If everything lands in the wrong order, switch closer.

  • Depth comparisons are hard-edged per pixel; antialiased intersections may look jaggy. Add a little softness, or render the elements with more samples.

  • softness is in depth units: for a depth pass in meters, 0.1 blends over 10 cm.

  • Merge — layer images in a fixed order
  • LensBlur — depth of field from the merged depth
  • GenerateDepth — estimate a depth pass from a plain image