Nodes/ComfyUI-RMAutomation/RM Set Latent Noise Mask
ComfyUI Node

RM Set Latent Noise Mask

Set a noise mask on your latents without crashing on an empty one

By Moser9815·Created 7 months ago·Updated 7 days ago· 0
RM Set Latent Noise Mask
  • samples
  • mask
  • LATENT
  • STATUS

ComfyUI ships a stock SetLatentNoiseMask node, so why would you reach for an RM one? Because the stock version quietly assumes you fed it a usable mask, and when you don't - when a detection node upstream returned nothing, when a mask got zeroed out by a math bug - the whole generation fails or, worse, inpaints somewhere you didn't intend. This node is the same idea with the guardrails bolted on: it sets the noise_mask on your latent samples and hands you back a plain-text STATUS so you can see what actually happened instead of guessing from the error log.

How it works

A latent "noise mask" tells the sampler how much denoising each pixel region should get. White areas denoise fully (that's the region that gets regenerated), black areas stay protected. It's the engine behind every regional rework and inpainting workflow: encode your image to a latent, attach the mask, sample, and the sampler only re-draws inside the masked area.

The node copies your LATENT samples and writes the mask in as the noise_mask key, reshaped to the (batch, 1, H, W) layout ComfyUI's samplers expect. The error handling is the point: if the mask is None, empty, or has a zero dimension, it prints a warning and hands your samples back untouched rather than throwing. You get a STATUS string ("Noise mask added" or "Noise mask not added") to prove which branch you were on.

Inputs and outputs that matter

Only a handful of fields exist, which is refreshing:

  • samples (LATENT, required) - your encoded latent, straight from a VAE Encode.
  • mask (MASK, optional) - the region to re-denoise. Leave it unconnected and the node becomes a no-op with a status message.
  • Outputs: LATENT (wire to your sampler) and STATUS (a STRING - stick it on a text display node, or just read it in the console).

How to install it

This ships in the RMAutomation pack, so install the pack once and every RM node comes along:

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

Restart ComfyUI (or hit Refresh in the Manager) and it'll show up under RMAutomation/Latent. ComfyUI Manager also finds it if you search "RMAutomation". Note the pack has no requirements.txt - this particular node is pure PyTorch, so nothing extra to install.

Common issues

The status string is your diagnostic. If you keep seeing "Noise mask not added," the mask is arriving empty or with a zero dimension - check whatever produced it before you blame the sampler. A classic trap: a mask that was resized to a different resolution than the latent. This node doesn't resize for you, so match the mask to the latent's spatial dimensions first. And if you want per-region control over how much denoise each area gets, chain this after RM Mask Denoise Remap in the same pack - that one converts mask brightness into denoise strength, and this one applies the result.

CategoryRMAutomation/Latent

Inputs (2)

NameTypeDefaultDescription
samplesLATENT
maskoptMASK

Outputs (2)

NameTypeDescription
LATENTLATENT
STATUSSTRING