Nodes/ComfyUI Layer Style/LayerMask: Shadow & Highlight Mask
ComfyUI Node Runs on cloud

LayerMask: Shadow & Highlight Mask

Shadow & Highlight Mask

By chflame163·Created 3 years ago·Updated 4 days ago· 3,113
LayerMask: Shadow & Highlight Mask
  • image
  • mask
  • shadow_mask
  • highlight_mask
â—„shadow_level_offset0â–º
â—„shadow_range0.25â–º
â—„highlight_level_offset0â–º
â—„highlight_range0.25â–º

This one builds masks out of brightness. Feed it an image and it hands back two masks: one covering the shadow (dark) areas, one covering the highlight (bright) areas. Nothing about shape or subject - purely tonal. It's the ComfyUI answer to the luminosity masks photographers live in: select the darks so you can lift or tint them without touching the brights, or grab the highlights to roll off a blown-out sky.

Why you'd want it: a huge amount of good color work is "do this thing, but only to the shadows" or "only to the highlights." Warm up the highlights and cool the shadows for a cinematic split-tone. Recover detail in crushed blacks by masking the shadows before an inpaint or a curves adjustment. Protect the highlights while you push exposure elsewhere. This node is what gives you the where - the mask - that all of those operations need. It pairs naturally with the pack's Color of Shadow & Highlight node, but the masks are generic, so you can route them anywhere.

The mechanism is a luminance threshold with a soft falloff. It reads the image's brightness and classifies pixels toward the shadow end or the highlight end, with a smooth transition rather than a hard cut so the masks blend cleanly. The controls tune where those tonal bands sit and how wide they are.

Four settings, two per band. shadow_range and highlight_range (0.01–0.99) set how much of the tonal scale each mask covers - a bigger range reaches further into the midtones, a smaller range keeps the mask to the extreme darks or brights only. shadow_level_offset and highlight_level_offset shift the threshold up or down (−99 to 99), so you can bias what counts as "shadow" brighter or darker without changing the width. Start with the ranges to get roughly the right coverage, then use the offsets to fine-tune where the edge lands. There's an optional mask input if you want to restrict the whole thing to a region you already have - say, only compute shadow/highlight masks on the subject, not the background.

Two outputs: shadow_mask and highlight_mask. Wire whichever you need into a composite, a color adjustment, a relight, or an inpaint. They're just masks - everything downstream treats them normally.

Install is the pack standard: search "ComfyUI Layer Style" in ComfyUI Manager, or cd ComfyUI/custom_nodes && git clone https://github.com/chflame163/ComfyUI_LayerStyle, then pip install -r requirements.txt and restart. No model downloads - it's tonal math, instant to load.

Practical notes. Because the masks are tonal and soft, don't expect crisp object boundaries - a bright shirt on your subject lands in the highlight mask right alongside the sky, which is correct behavior but not always what you want; combine with a subject mask via the optional input if you need to keep it local. And the usual LayerStyle caveat: if the node doesn't appear after installing the pack, the pack failed to import (a dependency conflict, the classic LayerStyle failure). Check the console for the red traceback, "Try Fix" in Manager, reinstall requirements. Once it's in, this is one of the quietly most useful nodes in the pack for anyone doing color work.

Category😺dzNodes/LayerMask

Inputs (6)

NameTypeDefaultDescription
imageIMAGE—
shadow_level_offsetINT0-99–99—
shadow_rangeFLOAT0.250.01–0.99—
highlight_level_offsetINT0-99–99—
highlight_rangeFLOAT0.250.01–0.99—
maskoptMASK—

Outputs (2)

NameTypeDescription
shadow_maskMASK—
highlight_maskMASK—