LayerMask: BlendIf Mask
Blend If Mask (Layer Style)
- image
- mask
- mask
Blend If Mask is a straight port of Photoshop's "Blend If" sliders, turned into a mask generator. Instead of masking by where something is, it masks by how bright or what color a pixel is - grab all the highlights, isolate the shadows, select only the reddest pixels. It's a luminosity/tonal masking tool, and if you do any serious compositing, color grading, or selective effects, this is a sharper instrument than drawing a mask by hand. Want to add glow only to the bright areas, or tint only the shadows? This builds that selection for you.
The mechanism: pick a channel, then define a tonal range on it, and the node outputs a mask that's white where pixels fall in that range and black where they don't. The soft-transition controls (the "range" values) feather the edges of the selection so it blends instead of hard-cutting, which is the difference between a natural-looking grade and an obvious cutout.
The inputs that carry the work:
blend_if- which channel to judge by:gray(overall luminance - the most common),red,green, orblue.black_point(0–254) andwhite_point(1–255) - the low and high ends of the tonal range you're selecting. Pixels between them get included. Narrow the gap to target a slice of tones; widen it to grab more.black_rangeandwhite_range- the feather. These soften the transition at each end so the mask ramps in gradually instead of snapping. This is the Photoshop trick of alt-dragging the Blend If slider to split it - same idea, and it's what keeps the result from looking cut out.invert_mask- flip the selection (grab everything outside the range instead).
An optional mask input lets you constrain the result to a region you already have. The single output is a mask you feed anywhere a mask goes - a composite, a selective filter, an inpaint, a color adjustment limited to those tones.
Where it shines: luminosity masks for compositing (blend a layer so only its highlights show through, the classic screen-mode look), targeting a grade at just the shadows or just the sky's blue, or building a selection from tonal content when there's no clean edge to trace. It rewards a bit of play - nudge the points and ranges and watch the mask preview until the selection lands where you want.
The thing to internalize is that this masks by tone, not by object. If you want "the person," this isn't it (reach for a segmentation node). If you want "the bright parts of the person's rim light," this is exactly it. And lean on the range (feather) controls - a Blend If mask with zero feather is usually too harsh; a little softness is what makes it usable.
Install comes with the ComfyUI Layer Style pack. ComfyUI Manager: search "ComfyUI Layer Style," install, restart. Manual: cd ComfyUI/custom_nodes && git clone https://github.com/chflame163/ComfyUI_LayerStyle, then pip install -r requirements.txt in the ComfyUI environment and restart. No model download for this one.
Pack-level caveat as always: Layer Style is large and dependency-heavy, and its most common failure is the whole pack showing "import failed" in the Manager (usually a transformers version conflict), which removes every node it contains - Blend If Mask included - from your menu at once. If it's not there, the pack didn't import: reinstall it, use the Manager's "Try Fix," and reinstall the requirements into ComfyUI's real Python environment if it persists.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| invert_mask | BOOLEAN | true | — |
| blend_if | COMBO | 4 options: gray, red, green, blue | |
| black_point | INT | 00–254 | — |
| black_range | INT | 00–255 | — |
| white_point | INT | 2551–255 | — |
| white_range | INT | 00–255 | — |
| maskopt | MASK | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| mask | MASK | — |