Nodes/ComfyUI-RMAutomation/RM Mask Combine
ComfyUI Node

RM Mask Combine

Combine body, face and object masks into one inpainting mask

By Moser9815·Created 7 months ago·Updated 7 days ago· 0
RM Mask Combine
  • body
  • face
  • mask

Inpainting logic in ComfyUI usually ends up as a small algebra problem: I want to re-draw the background, keep the person, and also protect that lamp. Masks express that as math, but hand-combining masks with composite nodes and blend modes is error-prone and hard to read. RMMaskCombine turns it into a wiring problem instead - you connect a body mask, a face mask, and as many object masks as you like, and it computes the combined mask with a defined formula instead of a pile of blend nodes.

How it works

The convention here is white = process, black = protect - the opposite of how some masking tools think, so worth stating out loud. The node's logic:

  • body + face + objects → invert(body) + face − objects
  • body + face → invert(body) + face
  • face + objects → face − objects
  • body alone → invert(body)
  • face alone → face
  • objects alone → invert(objects)

Read that the way the author intended: the body mask marks the person (protect them, hence the invert), the face mask marks the face (which you do want re-processed, so it's added back), and object masks mark things to keep out (subtracted). It resizes everything to the first valid mask's dimensions with bilinear interpolation, so resolution mismatches are handled rather than fatal.

The dynamic part is the Add Object button - each object mask you add becomes an object_N input, and they're all unioned (max) before being subtracted. If none of the inputs are valid, it returns None rather than a mask, so downstream nodes get an explicit "nothing to do" instead of garbage.

Inputs and outputs that matter

  • body (MASK, optional) - the person or main subject to protect.
  • face (MASK, optional) - the face region to include in the processed area.
  • object_N (MASK, optional, dynamic) - extra regions to exclude.
  • Output: mask (MASK) - feed into a Set Latent Noise Mask / denoise setup, or a mask-conditioning input.

How to install it

Part of the RMAutomation pack:

cd ComfyUI/custom_nodes
git clone https://github.com/Moser9815/ComfyUI-RMAutomation

Restart ComfyUI; it's under RMAutomation/Mask. Pure PyTorch, no extra deps.

Common issues

The white/black convention trips people up the most - if your result processes exactly the wrong area, flip your masks before connecting them. Second: this node combines, it doesn't feather. The output mask has whatever edges your source masks had, so if you see hard seams after sampling, blur the result (or rely on the sampler's own mask blur settings). And the None output when nothing's valid is deliberate - if a downstream node errors on "no mask," route the output through the pack's RM Mask Gate and handle it there. Remember the face mask is added to the processed region: if you're protecting the person entirely, don't connect a face mask at all.

CategoryRMAutomation/Mask

Inputs (2)

NameTypeDefaultDescription
bodyoptMASK
faceoptMASK

Outputs (1)

NameTypeDescription
maskMASK