FLUX.2 Klein Mask Ref Controller
Painting out parts of a reference before Klein ever sees them
- conditioning
- mask
- CONDITIONING
There are two ways to mask a reference in this pack, and they work at completely different layers - which is exactly the kind of thing that's obvious once you know it and confusing until then. Mask Ref Controller is the earlier, simpler one: it doesn't touch attention or token matching at all, it just directly edits the reference latent's pixel values before Klein ever looks at it.
What it's doing, and how it differs from the identity-transfer masks
This node reads one reference latent already sitting in your conditioning and multiplies the black regions of your mask by 1 - strength, leaving white regions untouched. At strength = 1, black regions get zeroed out entirely; at 0.5, they're held to half their original value; at 0, the mask has no effect and the reference passes through unchanged.
That's a fundamentally different operation from what Identity Feature Transfer Final's subject_mask_N inputs do. Those filter or isolate which reference tokens get pulled from inside the model's attention - Klein can still see the whole reference for context. This node mutates the encoded latent itself, upstream of any of that, so whatever gets zeroed out is genuinely gone from what the model sees, not just deprioritized.
The inputs that matter
conditioning- required, your existing conditioning with a reference already loaded via Multi ReferenceLatent.mask- required. Paint what you want to keep white by default.strength(optional, default1) - attenuation applied to black regions, as described above.invert_mask(optional) - flips black/white interpretation. Handy if you find it more natural to paint the area you want removed rather than the area you want kept.feather(optional) - Gaussian blur radius in latent pixels on the mask edge.0gives hard edges; raising it softens the transition so the cut doesn't look like a stencil.reference_index(optional) - which reference latent to attenuate, when multiple are connected. Matches the order set in Multi ReferenceLatent.
Output is a modified CONDITIONING, wired onward exactly like normal conditioning.
Installing it
ComfyUI Manager: search ComfyUI-Flux2Klein-Enhancer, install, restart. Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/capitan01R/ComfyUI-Flux2Klein-Enhancer.git
No extra Python dependencies.
Where people get burned
The biggest trap is reaching for this node when what you actually want is Identity Feature Transfer Final's masking. If your goal is "let this reference contribute identity but not its cluttered background," you probably want the attention-level masks on the identity-transfer node, which preserve Klein's ability to use the full reference for context while still filtering what gets pulled. Mask Ref Controller is closer to a blunt instrument: it's for cases where you genuinely want part of the reference gone from the model's input, full stop - isolating a garment, cutting out a background object, that kind of thing.
Second, feather = 0 gives hard latent-space edges, and because this operates in latent space rather than pixel space, a hard mask boundary can produce a visible seam or discontinuity in the output where the reference was cut. If you see an odd hard edge tracking your mask shape in the final image, raise feather before assuming something else is wrong.
Third, reference_index defaults to 0 - on any workflow with more than one reference connected, forgetting to set this means you're silently masking the wrong image.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| conditioning | CONDITIONING | — | |
| mask | MASK | — | |
| strengthopt | FLOAT | 1.000–1 | Attenuation strength in the BLACK regions of the mask. 1.0 = black regions multiplied by 0 (full attenuation). 0.5 = black regions kept at 50% of ref strength. 0.0 = mask ignored, ref passes through everywhere. |
| invert_maskopt | BOOLEAN | false | Flip black/white. Enable if you painted the area you want attenuated rather than preserved. |
| featheropt | INT | 00–64 | Gaussian blur radius (in latent pixels) on mask edges. 0 = hard edges. |
| reference_indexopt | INT | 00–7 | Which reference latent to attenuate when multiple are connected (0 = first). |
| debugopt | BOOLEAN | false | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| CONDITIONING | CONDITIONING | — |