Nodes/Eden.art nodesuite/Eden_DepthSlice_MaskVideo
ComfyUI Node Runs on cloud

Eden_DepthSlice_MaskVideo

Sweep a depth window through a scene

By edenartlabΒ·Created 3 years agoΒ·Updated 6 months agoΒ· 119
Eden_DepthSlice_MaskVideo
  • 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_mapIMAGEβ€”
slice_widthFLOAT0.100.01–0.99β€”
min_depthFLOAT0.000–1β€”
max_depthFLOAT1.000–1β€”
gamma_correctionFLOAT1.00.1–10β€”
n_framesINT1001–9223372036854776000β€”
reverseBOOLEANfalseβ€”
bounceBOOLEANfalseβ€”

Outputs (2)

NameTypeDescription
depth_slice_masksMASKβ€”
gamma_corrected_depth_mapMASKβ€”