Depth Rasterize Layers
Turn any image into a paper-cut diorama, no LoRA required
- image
- depth_map
- region_mask
- background
- layered_images
- layer_masks
- depth_quantized
- composited_image
- debug_preview
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
imageanddepth_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-compositegives you the finished diorama;all_layersexports 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_modetowhole_sequenceand add a littletemporal_smoothingso 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.
Inputs (40)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | RGB input image or video frame batch to turn into depth-cut paper layers. | |
| depth_map | IMAGE | Aligned grayscale depth map from a depth node such as Depth Anything. | |
| rasterization_levels | INT | 122–48 | Number of depth slices to cut from the image. More slices add depth detail. |
| output_mode | COMBO | composite | Return all cut layers, one selected layer, the final composite, masks, or a debug depth preview. |
| region_maskopt | MASK | Optional mask limiting where the paper-cut effect is applied. | |
| backgroundopt | IMAGE | Optional bottom plate for the composite output. | |
| selected_layeropt | INT | 00–47 | Layer index for single_layer or masks_only output. 0 is the nearest layer after depth normalization. |
| invert_depthopt | BOOLEAN | false | Swap near and far if your depth map is reversed. |
| normalization_modeopt | COMBO | per_frame | per_frame adapts each image, whole_sequence stabilizes video batches, manual uses depth_min/depth_max. |
| depth_minopt | FLOAT | 0.000-1000000–1000000 | Manual minimum depth. Used only when normalization_mode is manual. |
| depth_maxopt | FLOAT | 1.000-1000000–1000000 | Manual maximum depth. Used only when normalization_mode is manual. |
| depth_gammaopt | FLOAT | 1.000.1–4 | Curve the normalized depth before slicing. Higher values move more pixels toward near layers. |
| depth_bluropt | FLOAT | 1.00–24 | Blur the raw depth map before slicing to reduce noisy cut boundaries. |
| temporal_smoothingopt | FLOAT | 0.000–0.99 | Blend video depth with the previous frame to reduce flicker. |
| layer_smoothingopt | FLOAT | 1.00–24 | Smooth tiny depth islands after normalization for cleaner paper shapes. |
| mask_featheropt | FLOAT | 0.500–8 | Soft edge width at layer boundaries. Set 0 for crisp hard cuts. |
| layer_color_modeopt | COMBO | color_zones | Paper fill style: original RGB, one average color per layer, color zones, grayscale, or black/white. |
| color_zones_per_layeropt | INT | 42–24 | Number of flat color patches inside each depth slice when using color_zones. |
| color_brightnessopt | FLOAT | 0.00-1–1 | Brightness adjustment applied after the layer fill mode. |
| color_contrastopt | FLOAT | 1.000–3 | Contrast multiplier applied after the layer fill mode. |
| color_saturationopt | FLOAT | 1.000–3 | Saturation multiplier applied after the layer fill mode. |
| black_white_thresholdopt | FLOAT | 0.500–1 | Luminance cutoff for black_white mode. |
| enable_shadowopt | BOOLEAN | true | Drop a blurred offset shadow behind each paper layer in composite mode. |
| shadow_distanceopt | FLOAT | 80–96 | Shadow offset distance in pixels. |
| shadow_angleopt | FLOAT | 1350–360 | Shadow direction in degrees. 135 casts toward the lower-left. |
| shadow_bluropt | FLOAT | 60–48 | Gaussian blur radius for the shadow mask. |
| shadow_opacityopt | FLOAT | 0.350–1 | Shadow opacity. |
| shadow_color_ropt | FLOAT | 0.000–1 | Shadow red channel from 0 to 1. |
| shadow_color_gopt | FLOAT | 0.000–1 | Shadow green channel from 0 to 1. |
| shadow_color_bopt | FLOAT | 0.000–1 | Shadow blue channel from 0 to 1. |
| depth_scaled_shadowopt | BOOLEAN | true | Scale shadow offset by layer depth for a stronger stacked-paper feel. |
| enable_outlineopt | BOOLEAN | false | Draw a colored edge around each paper layer. |
| outline_widthopt | INT | 21–16 | Outline thickness in pixels. |
| outline_opacityopt | FLOAT | 0.500–1 | Outline blend strength. |
| outline_color_ropt | FLOAT | 0.000–1 | Outline red channel from 0 to 1. |
| outline_color_gopt | FLOAT | 0.000–1 | Outline green channel from 0 to 1. |
| outline_color_bopt | FLOAT | 0.000–1 | Outline blue channel from 0 to 1. |
| enable_layer_offsetopt | BOOLEAN | false | Shift layers by depth for a subtle parallax cutout effect. |
| offset_xopt | FLOAT | 0-128–128 | Horizontal parallax strength in pixels. |
| offset_yopt | FLOAT | 0-128–128 | Vertical parallax strength in pixels. |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| layered_images | IMAGE | Layer images: one batch entry per frame x layer, or the selected/debug image depending on output_mode. |
| layer_masks | MASK | Layer masks: alpha masks matching layered_images. |
| depth_quantized | IMAGE | Posterized grayscale depth map showing the cut depth bands. |
| composited_image | IMAGE | Final stacked paper-cut composite when output_mode is composite. |
| debug_preview | IMAGE | False-color debug view of depth layer IDs. |