Nodes/ComfyUI-Yuan/Mask To Gray
ComfyUI Node

Mask To Gray

Make a selection a uniform-strength mask, not a grayscale image

By the-hexer·Created 2 years ago·Updated 10 months ago· 15
Mask To Gray
  • mask
  • MASK
â—„gray_intensity0.30â–º
â—„invertfalseâ–º

The name is a lie, in the most useful way. "Mask To Gray" sounds like it converts your mask into a grayscale image you'd have to wire back into an image pipeline. It doesn't. It turns a full-strength mask into a uniform partial-strength mask - and that's the feature, not the bug.

Here's the mental model that makes ComfyUI masks click: a mask's value is basically a strength/alpha map. 1.0 means "fully selected, full effect," 0.0 means "not selected at all," and anything between is a soft partial. Most masks you generate (from Segment Anything, an inpainting node, a hand-drawn selection) come out as hard 0/1 regions. This node takes that hard selection and multiplies the whole thing down - so a white 1.0 region becomes 0.3, and you get "this exact area, at 30% strength," uniformly across it.

When you'd actually use it

Two classic cases. First, soft inpainting: you've masked a face or an object but don't want a full regenerate - mask it at 0.3–0.5 and the sampler blends instead of replacing, which is the same knob as turning down denoise strength but applied inside the mask. Second, any pass where a region should influence the result partially rather than absolutely - controlnet weight per-region, a masked second pass, a partial correction. Rather than sculpting feathered masks by hand, you dial one float.

How it works

Mechanically it's three lines: clamp the mask to 0–1, optionally invert it (1 - mask), then multiply the whole thing by gray_intensity. That's it.

  • mask - a proper MASK input. Worth noting the pack explicitly fixed the old masquerade-nodes bug where masks leaked out as IMAGE tensors and broke downstream generation; this node emits a real MASK, so it plugs straight into any mask slot.
  • gray_intensity - default 0.3, range 0–1. 1.0 leaves the mask unchanged; 0.0 zeroes everything out (nothing selected - an easy way to kill a pass silently). The interesting range is 0.01–0.7.
  • invert - flips the selection before scaling, so invert + 0.3 puts your 30% strength on everything outside the original mask.

Where people get burned

Don't expect a luminance conversion. If your source mask has feathered or soft edges, those get scaled too - you'll keep the softness, just dimmed. And this node does not add feathering; a hard-edged binary mask stays hard-edged, just at lower value. If you want a softened region you still need a blur/grow node before or after. Also keep in mind gray_intensity is uniform - this is "same strength everywhere," not a gradient tool.

Install

From ComfyUI Manager, search ComfyUI-MoneyMaker (or the repo name ComfyUI-Yuan) and install, then restart. Manual route:

cd ComfyUI/custom_nodes
git clone https://github.com/Cyber-Blacat/ComfyUI-Yuan

No models to download, no extra dependencies beyond what ComfyUI already ships (torch, numpy, opencv-python). You'll find it under MoneyMaker😺 in the node menu.

It's a narrow little utility - two knobs and a multiply - but if you've ever wanted "my whole selection, just softer," it's the exact tool, and it costs nothing to have installed.

CategoryMoneyMaker😺

Inputs (3)

NameTypeDefaultDescription
maskMASK—
gray_intensityFLOAT0.300–1—
invertBOOLEANfalse—

Outputs (1)

NameTypeDescription
MASKMASK—