Layer Stack Node (MD)
A whole layer stack in one node — 33 blend modes, a mask, and opacity
- background
- layer
- mask
- Composited Image
Compositing two images in ComfyUI is usually a pile of separate nodes - composite primitives, alpha juggling, size matching - and it's the exact kind of busywork a GIMP refugee wishes was one node. mdLayerStackNode is that node. Give it a background, a layer, pick a blend mode, and it composites them with proper alpha handling, a per-layer mask, and a global transparency slider. It's Photoshop/GIMP layer stacking as a single drop-in.
How it works
It's a port of GEGL's layer compositing, and the internals do the unglamorous work for you. Both images are normalized to RGBA (missing alpha becomes opaque), the layer and the mask are auto-resized to match the background with bilinear interpolation, and the per-pixel opacity is computed as:
layer alpha × mask × transparency
That opacity then drives a standard "over" composite - the blended RGB replaces the background in proportion to opacity, and the result alpha is computed properly so the output stays compositable. The blend mode list is the full GEGL lineup: Normal, Screen, Multiply, Overlay, Difference, Dissolve, Add, Subtract, Darken/Lighten Only, Color Dodge/Burn, Hard/Soft/Pin Light, Vivid Light, Halo, Negate, and the Merge-* channel modes, plus a few compositing oddities like Behind and Template.
Two modes behave specially and it's worth knowing: Clear zeroes the layer entirely (a hole-puncher), and Behind only composites through the background's transparent areas.
The inputs that matter
background- the base image.layer- what gets composited over it.blending_mode- 33 options; Normal, Screen, Multiply and Overlay cover 90% of real use.transparency- 0 to 1, default 1 (fully opaque). Your global opacity knob.mask- optional layer mask; white shows the layer, black hides it. This is the input that makes the node genuinely useful - a vignette mask, a gradient mask, whatever you generate upstream.
Output is a single Composited Image, ready for Save or further post.
Install
Same pack as the color nodes, and same easy install - no dependencies, no models:
cd ComfyUI/custom_nodes
git clone https://github.com/MdONeilsl/ComfyUI-MdColorMod
Restart ComfyUI, or search "MdColorMod" in ComfyUI Manager.
Where people get burned
Dissolve is random. It composites with random per-pixel noise, so it produces a different result every run - great if you actually want dither-ish grain, a nasty surprise if you were using it for a deterministic texture and wondering why the output keeps changing. If you need reproducibility, avoid Dissolve. The other common stumble: the auto-resize is a feature, but it silently scales your layer to the background - if your layer is a small texture meant to tile or stay small, this node will stretch it. Match sizes upstream when that matters. And remember the layer's own alpha is honored, so a cutout with transparency composites like it does in a real layer stack.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| background | IMAGE | The base image to which the layer will be composited. | |
| layer | IMAGE | The layer to composite over the background. | |
| blending_mode | COMBO | The blend mode to use when compositing the layer. | |
| transparency | FLOAT | 1.000–1 | Global transparency for the layer (0.0 = fully transparent, 1.0 = fully opaque). |
| maskopt | MASK | Optional mask to control where the layer is applied (white = visible, black = hidden). |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| Composited Image | IMAGE | Composited image result |