Nodes/Masquerade Nodes/Constant Mask
ComfyUI Node Runs on cloud

Constant Mask

A flat, solid-value mask for math and testing

By BadCafeCode·Created 3 years ago·Updated 2 years ago· 481
Constant Mask
  • copy_image_size
  • IMAGE
value0.00
explicit_height0
explicit_width0

Constant Mask does the least glamorous possible job: it makes a mask that's the same value everywhere, at whatever size you need. No image analysis, no painting, just a flat field of a single number. On its own that sounds almost pointless - but it's the kind of building block that shows up as a quiet dependency of other, more interesting operations, and the pack's own tips are blunt about where: it's generally used together with Combine Masks.

Think of it as a variable rather than a mask, in the algebra sense. A fully-white constant mask (value 1) combined with another mask via union gives you back all-white, regardless of what the other mask was - useful for testing whether a downstream chain handles a fully-masked case correctly. A fully-black one (value 0) combined via intersection clears everything, same logic. And because Combine Masks also does raw arithmetic ops like add and multiply, a constant mask set to some in-between value lets you scale or offset another mask uniformly - multiply a real mask by a Constant Mask at 0.5 and you've halved its intensity everywhere, useful for dialing back how strongly a mask applies without touching its shape.

The inputs that matter

  • value (FLOAT, default 0, range −8 to 8, step 0.01) - the flat value every pixel in the mask gets. In practice, for most uses you'll stay within the normal 0–1 mask range; the wider range exists because this node is also handy for raw math you plan to clamp or process later (Combine Masks with clamp_result off, for instance).
  • explicit_height, explicit_width - the mask's dimensions, only used if copy_image_size is left unwired.
  • copy_image_size (optional) - wire an image in here and the mask matches its size automatically, which is the more reliable option whenever you already have a reference image in the graph.

Output is the resulting flat mask.

Installing it

Constant Mask is part of Masquerade Nodes. Install through ComfyUI Manager (search "Masquerade Nodes") or manually: cd ComfyUI/custom_nodes && git clone https://github.com/BadCafeCode/masquerade-nodes-comfyui, then restart ComfyUI. As plain as nodes get - no models, no extra pip installs, nothing that can fail beyond the install itself.

Common issues

There's genuinely little to troubleshoot here - it's a single number broadcast across an array. The one real gotcha is size mismatches downstream: if you hand-typed explicit_width/explicit_height instead of wiring copy_image_size, and your actual image later changes resolution upstream (a common thing to happen while iterating on a workflow), the constant mask silently stays at the old size and any node combining it with the real mask will either error or misbehave on the mismatch. Wire copy_image_size whenever you can - it removes that whole failure mode by construction.

CategoryMasquerade Nodes

Inputs (4)

NameTypeDefaultDescription
valueFLOAT0.00-8–8
explicit_heightINT00–1048576
explicit_widthINT00–1048576
copy_image_sizeoptIMAGE

Outputs (1)

NameTypeDescription
IMAGEIMAGE