Nodes/MdColorMod/Layer Stack Node (MD)
ComfyUI Node

Layer Stack Node (MD)

A whole layer stack in one node — 33 blend modes, a mask, and opacity

By MdONeilsl·Created 2 months ago·Updated 2 months ago· 0
Layer Stack Node (MD)
  • background
  • layer
  • mask
  • Composited Image
blending_mode
transparency1.00

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.

Categorymd/layers

Inputs (5)

NameTypeDefaultDescription
backgroundIMAGEThe base image to which the layer will be composited.
layerIMAGEThe layer to composite over the background.
blending_modeCOMBOThe blend mode to use when compositing the layer.
transparencyFLOAT1.000–1Global transparency for the layer (0.0 = fully transparent, 1.0 = fully opaque).
maskoptMASKOptional mask to control where the layer is applied (white = visible, black = hidden).

Outputs (1)

NameTypeDescription
Composited ImageIMAGEComposited image result