Nodes/MKRShift_Nodes/Layer Stack Composite
ComfyUI Node

Layer Stack Composite

Base image plus up to four masked layers, blended in order

By criskb·Created 7 months ago·Updated 5 months ago· 0
Layer Stack Composite
  • base_image
  • layer_1
  • layer_1_mask
  • layer_2
  • layer_2_mask
  • layer_3
  • layer_3_mask
  • layer_4
  • layer_4_mask
  • image
  • combined_mask
  • layer_info
layer_1_opacity1.00
layer_1_blend_modenormal
resize_modestretch
layer_2_opacity1.00
layer_2_blend_modenormal
layer_3_opacity1.00
layer_3_blend_modenormal
layer_4_opacity1.00
layer_4_blend_modenormal
mask_feather0.0

Every serious ComfyUI workflow eventually needs to combine images the way a compositor would: a background, a subject on top, a light-wrap layer over that, a vignette to finish. Doing that with a pile of blend nodes gets ugly fast. MKRLayerStackComposite is the pack's "layers panel": one node that stacks a base image plus up to four extra layers, each with its own mask, opacity, and blend mode, composited top to bottom. If you've ever wished a Comfy graph had a layers palette, this is as close as it gets.

How it works

You provide base_image and a layer_1 (required), then optionally layers 2 through 4. Each layer composites over whatever has been built so far, in order: layer 1 first, then 2, 3, 4 - so layer 4 ends up on top. Per layer you set:

  • opacity - how much of it shows through (0 to 1).
  • blend_mode - eight options: normal, screen, multiply, overlay, soft_light, add, lighten, darken. Screen/add for light and glows, multiply for shading and texture, overlay for punch - the usual suspects.
  • an optional mask - a MASK tensor controlling where the layer shows.

The resize behavior is set once via resize_mode: stretch fits each layer to the canvas (distorting aspect), contain fits it inside (letterboxing), cover fills the canvas (cropping overflow). One setting applies to all layers, which is simpler than per-layer - and usually fine, since layers usually share a canvas.

The mask handling is where the pack's thoughtfulness shows. If a layer image carries an alpha channel, that alpha is used automatically. If you also connect a mask, the mask is multiplied with the layer's own alpha - so you get "this subject, only visible where my mask says." And mask_feather softens mask edges across the whole stack in one knob, which is the difference between a hard cutout and a comp that sits in the image.

Outputs

  • image - the composited result.
  • combined_mask - the union of every layer's visible contribution, as a MASK. Wire this into anything that needs to know where the stacked layers actually cover the frame - a detailer, a save-time matte, or a follow-up pass that should only touch composited regions.
  • layer_info - a string describing what got applied ("Layer 1: mode=screen, opacity=0.80 | ..."). Feed it to a text display for a quick audit.

Installing it

Part of the pack:

# ComfyUI Manager: search "MKRShift Nodes", install, restart.
# or:
cd ComfyUI/custom_nodes
git clone https://github.com/criskb/MKRShift_Nodes
# restart ComfyUI

No extra dependencies, no models.

The honest take

This is a solid, unglamorous workhorse - the kind of node that quietly sits in the middle of comp-heavy graphs. Two things to know before you lean on it. First, the blend math is straightforward PIL/numpy territory: don't expect ACES-linear compositing or OCIO color management. If you're doing VFX that needs to hand off to Nuke or a color pipeline, you still want to manage color space yourself - this node blends in whatever space its inputs are in. Second, it's bottom-up ordered, so if you wire layer 3 and expect it to appear behind layer 1, you need to think about order before you connect. Stack order is the one thing you can't adjust after the fact without rewiring. For masking-driven compositing inside a generation pipeline - subject onto background, glow over subject, vignette on top - it beats a tower of blend nodes every time.

CategoryMKRShift Nodes/VFX/Composite

Inputs (19)

NameTypeDefaultDescription
base_imageIMAGE
layer_1IMAGE
layer_1_opacityFLOAT1.000–1
layer_1_blend_modeCOMBOnormal8 options: normal, screen, multiply, overlay, soft_light, add, +2
resize_modeCOMBOstretch3 options: stretch, contain, cover
layer_1_maskoptMASK
layer_2optIMAGE
layer_2_maskoptMASK
layer_2_opacityoptFLOAT1.000–1
layer_2_blend_modeoptCOMBOnormal8 options: normal, screen, multiply, overlay, soft_light, add, +2
layer_3optIMAGE
layer_3_maskoptMASK
layer_3_opacityoptFLOAT1.000–1
layer_3_blend_modeoptCOMBOnormal8 options: normal, screen, multiply, overlay, soft_light, add, +2
layer_4optIMAGE
layer_4_maskoptMASK
layer_4_opacityoptFLOAT1.000–1
layer_4_blend_modeoptCOMBOnormal8 options: normal, screen, multiply, overlay, soft_light, add, +2
mask_featheroptFLOAT0.00–128

Outputs (3)

NameTypeDescription
imageIMAGE
combined_maskMASK
layer_infoSTRING