Nodes/Depth Layer Rasterizer/Depth Rasterize Layers
ComfyUI Node

Depth Rasterize Layers

Turn any image into a paper-cut diorama, no LoRA required

By maDcaDDie2000·Created 2 months ago·Updated 2 months ago· 1
Depth Rasterize Layers
  • image
  • depth_map
  • region_mask
  • background
  • layered_images
  • layer_masks
  • depth_quantized
  • composited_image
  • debug_preview
rasterization_levels12
output_modecomposite
selected_layer0
invert_depthfalse
normalization_modeper_frame
depth_min0.000
depth_max1.000
depth_gamma1.00
depth_blur1.0
temporal_smoothing0.00
layer_smoothing1.0
mask_feather0.50
layer_color_modecolor_zones
color_zones_per_layer4
color_brightness0.00
color_contrast1.00
color_saturation1.00
black_white_threshold0.50
enable_shadowtrue
shadow_distance8
shadow_angle135
shadow_blur6
shadow_opacity0.35
shadow_color_r0.00
shadow_color_g0.00
shadow_color_b0.00
depth_scaled_shadowtrue
enable_outlinefalse
outline_width2
outline_opacity0.50
outline_color_r0.00
outline_color_g0.00
outline_color_b0.00
enable_layer_offsetfalse
offset_x0
offset_y0

Depth maps are usually the boring middle step of a workflow - you generate one with Depth Anything so a ControlNet can steer your next generation, or so you can fake a little parallax. Depth Rasterize Layers is the rare node that makes the depth map the whole show. Feed it an image plus a depth map and it slices the scene into flat paper layers, fills each slice with stylized color, and stacks them back up with soft drop shadows - a paper-cut diorama straight out of ComfyUI, with no LoRA, no ControlNet, no external styling tool, and nothing that leaves your GPU.

The name is a lie in the best way: "rasterizer" sounds like you're about to install a render engine, but this is a pure torch/numpy image-processing pass. requirements.txt is two lines - torch and numpy. No model files to download, no API key, no weights over a gigabyte. Your only real dependency is upstream: a good depth map, which the README says comes from a node like Depth Anything or Depth Anything V2 (both ship in Fannovel16's comfyui_controlnet_aux). V2 Large is the community default for a reason - cleaner edges and better behavior on glass and reflections than v1.

How it works

The node normalizes the depth map, lets you gamma-curve and blur it, then quantizes it into rasterization_levels (default 12) bands. Each band becomes a mask, and each mask gets filled with one of the layer_color_mode styles: original keeps the real pixels inside the slice, flat_average paints each layer one solid color, color_zones splits each layer into flat average-color patches for that cel-shaded papercraft look, and grayscale / black_white go monochrome. Then it composites far-to-near, dropping a blurred offset shadow behind each layer (depth_scaled_shadow is on by default, so deeper layers cast further) and optionally drawing outlines or shifting whole layers for a parallax cutout effect.

The inputs that matter

  • image and depth_map - the only required ones. The depth map just needs to be aligned with the image and roughly the same scene.
  • rasterization_levels - the big creative dial. 12 is a good middle; more slices reads as photographic, fewer reads as a flat graphic stencil.
  • output_mode - composite gives you the finished diorama; all_layers exports every cut layer so you can reassemble in Photoshop or send pieces to a plotter.
  • invert_depth - flip this when near and far come out backwards.
  • For video, set normalization_mode to whole_sequence and add a little temporal_smoothing so the depth bands stop flickering frame to frame.

You'll get five outputs but only really care about two: composited_image (the finished stack - wire it to a SaveImage) and layer_masks (the per-layer alphas for export or further compositing). depth_quantized shows the posterized bands, debug_preview is a false-color layer-ID view for diagnosing weird cuts.

Installing it

Boring in a good way. ComfyUI Manager, search "Depth Layer Rasterizer", or:

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

Then restart ComfyUI. Since the only dependencies are torch and numpy you almost certainly already have, that pip line is often a no-op.

Where people get burned

The depth map is the actual input - the node doesn't invent depth. Run it without one and it works but every layer looks identical, which reads as "broken." Noisy depth gives jagged cut edges, so bump depth_blur and layer_smoothing before blaming the node. And remember the batch is frames × layers, so for long video keep rasterization_levels conservative or you'll feel it in VRAM. It's a young pack (v0.1.0, MIT) and a small niche - if the composite looks busy, fewer levels plus mask_feather at 0 is the fast route to a clean minimal look.

Categorydepth/layers

Inputs (40)

NameTypeDefaultDescription
imageIMAGERGB input image or video frame batch to turn into depth-cut paper layers.
depth_mapIMAGEAligned grayscale depth map from a depth node such as Depth Anything.
rasterization_levelsINT122–48Number of depth slices to cut from the image. More slices add depth detail.
output_modeCOMBOcompositeReturn all cut layers, one selected layer, the final composite, masks, or a debug depth preview.
region_maskoptMASKOptional mask limiting where the paper-cut effect is applied.
backgroundoptIMAGEOptional bottom plate for the composite output.
selected_layeroptINT00–47Layer index for single_layer or masks_only output. 0 is the nearest layer after depth normalization.
invert_depthoptBOOLEANfalseSwap near and far if your depth map is reversed.
normalization_modeoptCOMBOper_frameper_frame adapts each image, whole_sequence stabilizes video batches, manual uses depth_min/depth_max.
depth_minoptFLOAT0.000-1000000–1000000Manual minimum depth. Used only when normalization_mode is manual.
depth_maxoptFLOAT1.000-1000000–1000000Manual maximum depth. Used only when normalization_mode is manual.
depth_gammaoptFLOAT1.000.1–4Curve the normalized depth before slicing. Higher values move more pixels toward near layers.
depth_bluroptFLOAT1.00–24Blur the raw depth map before slicing to reduce noisy cut boundaries.
temporal_smoothingoptFLOAT0.000–0.99Blend video depth with the previous frame to reduce flicker.
layer_smoothingoptFLOAT1.00–24Smooth tiny depth islands after normalization for cleaner paper shapes.
mask_featheroptFLOAT0.500–8Soft edge width at layer boundaries. Set 0 for crisp hard cuts.
layer_color_modeoptCOMBOcolor_zonesPaper fill style: original RGB, one average color per layer, color zones, grayscale, or black/white.
color_zones_per_layeroptINT42–24Number of flat color patches inside each depth slice when using color_zones.
color_brightnessoptFLOAT0.00-1–1Brightness adjustment applied after the layer fill mode.
color_contrastoptFLOAT1.000–3Contrast multiplier applied after the layer fill mode.
color_saturationoptFLOAT1.000–3Saturation multiplier applied after the layer fill mode.
black_white_thresholdoptFLOAT0.500–1Luminance cutoff for black_white mode.
enable_shadowoptBOOLEANtrueDrop a blurred offset shadow behind each paper layer in composite mode.
shadow_distanceoptFLOAT80–96Shadow offset distance in pixels.
shadow_angleoptFLOAT1350–360Shadow direction in degrees. 135 casts toward the lower-left.
shadow_bluroptFLOAT60–48Gaussian blur radius for the shadow mask.
shadow_opacityoptFLOAT0.350–1Shadow opacity.
shadow_color_roptFLOAT0.000–1Shadow red channel from 0 to 1.
shadow_color_goptFLOAT0.000–1Shadow green channel from 0 to 1.
shadow_color_boptFLOAT0.000–1Shadow blue channel from 0 to 1.
depth_scaled_shadowoptBOOLEANtrueScale shadow offset by layer depth for a stronger stacked-paper feel.
enable_outlineoptBOOLEANfalseDraw a colored edge around each paper layer.
outline_widthoptINT21–16Outline thickness in pixels.
outline_opacityoptFLOAT0.500–1Outline blend strength.
outline_color_roptFLOAT0.000–1Outline red channel from 0 to 1.
outline_color_goptFLOAT0.000–1Outline green channel from 0 to 1.
outline_color_boptFLOAT0.000–1Outline blue channel from 0 to 1.
enable_layer_offsetoptBOOLEANfalseShift layers by depth for a subtle parallax cutout effect.
offset_xoptFLOAT0-128–128Horizontal parallax strength in pixels.
offset_yoptFLOAT0-128–128Vertical parallax strength in pixels.

Outputs (5)

NameTypeDescription
layered_imagesIMAGELayer images: one batch entry per frame x layer, or the selected/debug image depending on output_mode.
layer_masksMASKLayer masks: alpha masks matching layered_images.
depth_quantizedIMAGEPosterized grayscale depth map showing the cut depth bands.
composited_imageIMAGEFinal stacked paper-cut composite when output_mode is composite.
debug_previewIMAGEFalse-color debug view of depth layer IDs.