Nodes/ComfyUI-CustomNodePacks/Layer Effect: Drop Shadow (MEC)
ComfyUI Node

Layer Effect: Drop Shadow (MEC)

A real drop shadow, with an effect_mask you can reuse

By Code2Collapse·Created 7 months ago·Updated 2 days ago· 56
Layer Effect: Drop Shadow (MEC)
  • layer_image
  • background_image
  • layer_mask
  • image
  • effect_mask
  • report
invert_masktrue
blend_mode
opacity50
distance_x25
distance_y25
grow6
blur18
shadow_color#000000
dissolve_seed0

Why this exists

Photoshop's layer styles - drop shadow, stroke, inner glow - became a de-facto retouching vocabulary, and people kept wanting them in ComfyUI. The pack that shipped them is chflame163's ComfyUI_LayerStyle, which is enormous: a README that's broken browsers for people just trying to read it, a long dependency list, and a couple of hundred nodes including things that call out to Google's API if you hand them a key. Community threads about whether it's safe to install landed on a shrug - mostly it's ML libraries, but it's a big surface for eight compositing effects.

The LayerEffect nodes in this pack are a port of exactly that: the eight effects, torch-native, standalone, no upstream dependency. If you want a drop shadow and not a second ecosystem, that's the trade. There are also four upstream defects fixed here, per the source header - zero-offset shadows used to crash, a mask of a different size was silently replaced with solid white (turning your shadow into a full-frame rectangle), a missing mask returned a Python list through an IMAGE socket, and RGBA leaked onto a socket that's documented as three-channel. The sign of distance_x/distance_y was also deliberately un-inverted: positive moves right and down, which is what you'd guess and not what upstream did.

How the shadow is built

Shift the matte by distance_x/distance_y, expand it by grow, blur it by blur, and you have the shadow matte. Then a solid fill in shadow_color is blended onto the background through the selected blend mode at the chosen opacity, and the result is composited onto the plate through the shadow matte. Finally the layer itself is composited on top through the layer matte, so the subject sits over its own shadow.

effect_mask is not the shadow matte: it's the shadow footprint minus the layer - the visible cast band, not the part hidden behind the subject. That's the useful version for compositing, since it's the region you'd otherwise want to grade or blur separately.

Inputs

  • layer_image - the foreground. Its alpha defines the shadow if you don't wire a mask.
  • layer_mask (optional) - the matte. You need one of the two. With a 3-channel image and nothing wired, the node raises needs a layer mask rather than guessing.
  • invert_mask - defaults to true, and it really does invert. A normal ComfyUI mask is white-on-subject; leaving the default tells the node your layer is everything except your matte, which puts the shadow around the background blob and sends you hunting for a bug that isn't there. Flip it and look at the output.
  • distance_x / distance_y - pixels, positive right/down. Both at 0 is fine now (upstream crashed).
  • grow - expands the matte before blurring. Negative pulls it inside, which is the fix for a tight contact shadow that's haloing out from under the object.
  • blur - Gaussian radius on the shadow matte. This is your softness dial; it does more for realism than distance does.
  • shadow_color - hex. A pure #000000 shadow at high opacity is the "sticker" look; a dark tinted value at 50–70 reads better.
  • blend_mode / opacity - 30 modes including multiply, screen, overlay and dissolve. Note that dissolve is stochastic: here the dissolve_seed is a fixed widget, so it holds still across a sequence. Upstream reseeded per frame and dissolved shadows flickered in video.
  • background_image (optional) - the plate. Leave it empty and you're compositing onto a transparent canvas, which as an IMAGE output means black where nothing was drawn.

Outputs: image, effect_mask, report (a string listing what ran, including mask resizes and clamped values).

Install

ComfyUI Manager → search "CustomNodePacks", or:

cd ComfyUI/custom_nodes
git clone https://github.com/Code2Collapse/ComfyUI-CustomNodePacks

Restart ComfyUI. Required deps across the pack are opencv-python, scipy, safetensors; this node is tier 1 (no models, no VRAM). And per the README - which is unusually blunt about it for good reason - check your versions before running pip install -r requirements.txt; the list includes libraries ComfyUI already ships, and overwriting them is how you break your install rather than fix it.

Common issues

  • Shadow appears around the whole frame. You're seeing the upstream behaviour this port fixed (mask size mismatch → solid white), or you're on an older checkout. Update.
  • Shadow direction is backwards from what you expected. You're remembering upstream LayerStyle's sign convention, not this one's. Positive is right and down here.
  • The shadow looks like a cut-out outline. grow too high with blur too low - the matte is bigger but still sharp. Real shadows get softer as they spread, so raise blur with grow.
  • The comp has a hard rectangular boundary. Your background_image and layer_image didn't match sizes; they're aligned by the node's batch alignment, and a mismatch shows up as a seam. Match them.
CategoryMEC/LayerEffects

Inputs (12)

NameTypeDefaultDescription
layer_imageIMAGEForeground layer whose alpha defines the cast shadow.
invert_maskBOOLEANtrueFlip mask polarity when your matte is white-on-black.
blend_modeCOMBO30 options: normal, dissolve, darken, multiply, color burn, linear burn, +24
opacityINT500–100
distance_xINT25-9999–9999Horizontal offset in pixels. Positive moves the shadow right — the opposite of the upstream LayerStyle node, which negated it.
distance_yINT25-9999–9999Vertical offset in pixels. Positive moves the shadow down — the opposite of the upstream LayerStyle node, which negated it.
growINT6-9999–9999Expand the shadow before blurring. Positive spreads it past the subject edge; negative pulls it inside, which keeps a tight contact shadow from haloing.
blurINT180–1000Gaussian blur radius on the shadow matte.
shadow_colorSTRING#000000
dissolve_seedINT00–2147483647Only used by the 'dissolve' blend mode. Upstream reseeds every frame, so a dissolve flickers through a sequence; a fixed seed here holds still.
background_imageoptIMAGEPlate; empty = transparent canvas (V3 union).
layer_maskoptMASK

Outputs (3)

NameTypeDescription
imageIMAGE
effect_maskMASK
reportSTRING