Nodes/ComfyUI Inpaint Nodes/Denoise to Compositing Mask
ComfyUI Node Runs on cloud

Denoise to Compositing Mask

The missing link for Differential Diffusion

By Acly·Created 3 years ago·Updated 2 months ago· 1,224
Denoise to Compositing Mask
  • mask
  • mask
offset0.10
threshold0.20

This is a specialist node, and it's fine if you've never needed it - it exists to solve one specific problem that only shows up once you're using ComfyUI's Differential Diffusion node, which lets a mask control per-pixel denoise strength instead of a simple on/off region. The problem: that same mask is tempting to reuse for compositing (blending the generated result back over the original), but it's the wrong tool for the job if you do, and this node is the fix.

The problem it solves

A denoise-strength mask has values across the whole 0–1 range, because that's the point - different parts of the image get denoised by different amounts. If you use that mask directly for alpha-blending your composite, you defeat the purpose of Differential Diffusion entirely: regions with low denoise strength barely get touched by generation but also barely get blended in, which isn't what you want. Skip blending altogether instead, and you get visible quality degradation in the low-strength regions where generation was too weak to look intentional but strong enough to look wrong. Neither option works. This node builds you a third mask, specifically shaped for compositing, derived from the denoise mask but not identical to it.

How it works

Two parameters define a mapping: values below offset get clamped to 0, values above threshold get clamped to 1, and everything between the two gets linearly mapped from [offset → threshold] onto [0 → 1]. In effect, it steepens the transition zone so your compositing mask commits to "blended" or "not blended" faster than the raw denoise mask does, while still respecting the same rough boundary.

Inputs and outputs

  • mask - your Differential Diffusion denoise mask.
  • offset (FLOAT, default 0.1, 0–1) - values below this become 0.
  • threshold (FLOAT, default 0.2, 0.01–1) - values above this become 1.

Output is a single mask, ready for a compositing node like ImageCompositeMasked.

Installing it

Part of the same pack as everything else covered here - ComfyUI Manager (search "ComfyUI Inpaint Nodes"), or:

cd ComfyUI/custom_nodes
git clone https://github.com/Acly/comfyui-inpaint-nodes.git

Restart ComfyUI. No model needed for this one - it's a pure mask remapping.

Common issues

This node has nothing to do if you're not using Differential Diffusion. It's built specifically for that pairing; a plain inpaint mask on a standard KSampler workflow doesn't need this step at all - go straight to compositing with the mask you already have.

Offset and threshold are close together by default (0.1 and 0.2) on purpose - the goal is a fairly sharp transition, since a compositing mask benefits from committing rather than blending gradually the way a denoise-strength mask should. If your composite still looks too soft or too abrupt, that gap is the first thing to widen or narrow.

Categoryinpaint

Inputs (3)

NameTypeDefaultDescription
maskMASK
offsetFLOAT0.100–1
thresholdFLOAT0.200.01–1

Outputs (1)

NameTypeDescription
maskMASK