Nodes/Runtime44 ComfyUI Nodes/Runtime44 Mask Sampler
ComfyUI Node

Runtime44 Mask Sampler

Redraw one region, leave the rest of the frame untouched

By runtime44·Created 2 years ago·Updated 2 years ago· 42
Runtime44 Mask Sampler
  • model
  • positive
  • negative
  • latent
  • mask
  • LATENT
seed0
steps20
cfg8.0
sampler_name
scheduler
denoise1.00
mask_feather13
mask_dilation0

The Runtime44 Mask Sampler is the node you reach for when you want to regenerate exactly one part of an image and have everything else come back bit-identical. Fix a mangled hand, swap an object, redraw a face you don't like - the mask says where, and the sampler touches nothing outside it. It's the "masked inpainting" story from the ComfyUI pack of the same name (Runtime44 ComfyUI Nodes), and the author credits Impact Pack's SEGS detailer and Segment Anything as the inspiration, so the lineage is good even if the pack is small.

This is one of the cases where a mask still beats the instruction-edit models. Flux Kontext and Qwen-Image-Edit are great until you need the rest of the image to stay exactly where it is - masked sampling guarantees the unmasked pixels never move, which is precisely what those whole-frame editors can't promise.

How it works

The node is a thin, smart wrapper around ComfyUI's common_ksampler. It takes your mask, runs it through two preprocessing steps, then attaches it to the latent as a noise_mask before sampling. That noise_mask is the whole trick: the sampler applies noise and denoises only inside the masked region, and leaves everything outside it alone.

The two preprocessing steps matter more than people expect:

  • mask_dilation expands the mask (positive values) or shrinks it (negative) using OpenCV morphology. Useful when your mask is slightly too tight around a face or too wide around an object.
  • mask_feather blurs the mask edge with a heavy Gaussian blur (kernel is feather × 2 + 1, sigma is huge) so the redrawn region melts into the original instead of showing a hard seam. Default 13 is quite soft; drop it toward 4–6 if you want a crisper boundary.

Inputs and outputs

The inputs that matter, in order:

  • mask - the region to regenerate. Feed it from a SAM or BiRefNet segmentation, an attention-mask node, or any MASK output you have lying around. This is the input you'll actually spend time on.
  • denoise - default 1.0 means the masked region is fully redrawn. Lower it (0.3–0.6) for subtle blends like fixing a color cast inside the region without changing what's there.
  • mask_dilation and mask_feather - described above.

Everything else is the usual sampler fare: model, positive, negative, latent, seed, steps, cfg, sampler_name, scheduler. The output is a single LATENT, which you wire into a VAE Decode like you would any sampler's output.

Installing

The pack is called Runtime44 ComfyUI Nodes in ComfyUI Manager - search "Runtime44" and install, or do it by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/runtime44/comfyui_r44_nodes
cd comfyui_r44_nodes
python -m pip install -r requirements.txt   # or: uv pip install -r requirements.txt

Then restart ComfyUI. The requirements pull opencv-python and torchvision, which this node's mask math actually uses - so don't skip the pip step even though they may already be in your environment. The pack also lists the heavy CUDA wheels (cupy-cuda12x, cucim); this node doesn't need them, but the shared requirements file installs them anyway.

Things to know before you burn an hour

The whole latent goes through the sampler, not just the masked region - the mask just tells it where to add noise. So VRAM cost tracks your full image size, and on a 2K render with a tiny mask, you're paying for the whole thing. That's exactly what the pack's Tiled Mask Sampler sibling is for.

Two honesty notes. The pack has been dormant since mid-2024 (last commit was July of that year), so don't expect fixes to arrive. And there's essentially no community tutorial base for it - you're on your own with the dials, which is why it's worth treating mask_feather and denoise as your two real controls and everything else as the sampler settings you already know.

Categorysampling

Inputs (13)

NameTypeDefaultDescription
modelMODEL
positiveCONDITIONING
negativeCONDITIONING
latentLATENT
maskMASK
seedINT00–18446744073709550000
stepsINT201–10000
cfgFLOAT8.00–100
sampler_nameCOMBO34 options: euler, euler_cfg_pp, euler_ancestral, euler_ancestral_cfg_pp, heun, heunpp2, +28
schedulerCOMBO9 options: normal, karras, exponential, sgm_uniform, simple, ddim_uniform, +3
denoiseFLOAT1.000–1
mask_featherINT130–10000
mask_dilationINT0-10000–10000

Outputs (1)

NameTypeDescription
LATENTLATENT