Nodes/Eden.art nodesuite/Depth Slice Mask Video
ComfyUI Node Runs on cloud

Depth Slice Mask Video

Sweep a depth window through a scene

By edenartlab·Created 3 years ago·Updated 10 days ago· 120
Depth Slice Mask Video
  • depth_map
  • depth_slice_masks
  • gamma_corrected_depth_map
◄slice_width0.10►
◄min_depth0.00►
◄max_depth1.00►
◄gamma_correction1.0►
◄n_frames100►
◄reversefalse►
◄bouncefalse►

Depth maps are great for separating things, but they're even better when you let a "depth window" travel through them. Eden_DepthSlice_MaskVideo is the animated cousin of DepthSlicer: instead of cutting the depth map into static layers with k-means clustering, it sweeps a sliding slice from near to far (or far to near) across n_frames, producing a mask video where each frame reveals a different depth band. One depth map in, a whole animation out.

It's the mechanism behind the "focus travels through the scene" look - objects pop into mask existence one depth layer at a time - and it composes beautifully with frame-by-frame inpainting to make content reveal or regenerate in depth order.

How it works

The node takes a depth map (bright = close, as the KB's depth essay frames it) and normalizes it to 0–1, then optionally applies gamma_correction - raising the value brightens mid-tones and shifts where the slice bands land, which is your main way to bias the sweep toward near or far detail. It then marches a window of width slice_width from min_depth to max_depth across the depth range, one step per frame, and each frame becomes a binary mask showing which pixels fall inside the current window.

Two animation controls round it out:

  • reverse - flips the direction of the sweep.
  • bounce - runs the sweep forward, then back, so the animation loops instead of snapping. The code halves the frame budget for the forward pass and concatenates the reverse, giving you a smooth ping-pong.

Inputs and outputs

  • depth_map - IMAGE, the depth map to sweep.
  • slice_width (default 0.1) - how wide the depth band is. Narrower = more slices visible across the animation.
  • min_depth / max_depth (0 / 1) - the depth range to sweep. Tighten these to restrict the sweep to part of the scene.
  • gamma_correction (default 1) - depth curve shaping, as above.
  • n_frames (default 100) - length of the mask animation.
  • reverse, bounce - direction and looping.

Outputs: depth_slice_masks (the MASK video - one frame per depth step) and gamma_corrected_depth_map (the depth map after gamma, as a MASK), which is handy if you want to see exactly what the gamma did.

How to use it

The pattern is the same "mask → inpaint" recipe as DepthSlicer but animated: convert each mask frame to a latent mask, run a masked inpaint pass per frame, and you get a video where content regenerates in strict depth order - the background changes first, then the mid-ground, then the foreground, like a camera focus pulling through the scene. The KB's inpainting essay backs the approach: masked inpainting guarantees the unmasked region stays pixel-identical, which is exactly what keeps this frame-stable. Feed it a good depth map (MiDaS-class preprocessors) and start with a wide slice_width (0.2–0.3) to avoid a too-thin, noisy reveal.

Installing

One of 70+ nodes in edenartlab/eden_comfy_pipelines (Eden.art nodesuite):

cd ComfyUI/custom_nodes
git clone https://github.com/edenartlab/eden_comfy_pipelines.git
cd eden_comfy_pipelines
pip install -r requirements.txt

Or ComfyUI Manager → search "Eden". Pure torch math - no extra model downloads beyond your depth map source.

Gotchas

The output is MASK, not IMAGE - so unlike DepthSlicer you're already in mask territory, which is convenient but means you can't just preview it as an image without conversion. Watch n_frames × resolution: a 100-frame mask batch at high res eats VRAM like any stacked animation. And remember the depth map gets normalized internally, so extremely flat or extremely contrasty maps will behave - but you'll get better sweeps from a clean, well-lit depth source. If the sweep looks wrong, gamma_correction is your first lever, not slice_width.

CategoryEden 🌱/Depth

Inputs (8)

NameTypeDefaultDescription
depth_mapIMAGEDepth map (white = near). Only the first channel is used.
slice_widthFLOAT0.100.01–0.99Thickness of the depth band that is visible in each frame (in normalized depth).
min_depthFLOAT0.000–1Depth where the sweep starts.
max_depthFLOAT1.000–1Depth where the sweep ends.
gamma_correctionFLOAT1.00.1–10Gamma applied to the normalized depth map before slicing.
n_framesINT1001–9223372036854776000Number of output mask frames.
reverseBOOLEANfalseSweep from far to near instead of near to far.
bounceBOOLEANfalseSweep forward then back within the same number of frames.

Outputs (2)

NameTypeDescription
depth_slice_masksMASKOne mask per frame covering the current depth band.
gamma_corrected_depth_mapMASKThe normalized, gamma-corrected depth map.