PC: Attach Mask
Attach Mask — feeding regional masks to your prompt with IMASK()
- clip
- mask
- CLIP
This is the plumbing that makes regional prompting possible inside a PCTextEncode-family prompt: it attaches a MASK to your CLIP object so that mask becomes something you can reference by name from inside your prompt text, via the IMASK() function. Without this node, IMASK() in your prompt has nothing to point at.
What it does
You generate a mask however you normally would - hand-painted, from a segmentation node, whatever your workflow already does - and feed it in here along with your CLIP. The node attaches it to the CLIP object rather than transforming the CLIP itself; the CLIP that comes out is functionally the same model, it just now carries an association to your mask. Downstream, when PCTextEncode (or PCLazyTextEncode) parses your prompt and hits an IMASK() call, it looks up the mask you attached here and restricts that portion of the prompt's influence to the masked region.
The node is explicit about one behavior that matters if you're building anything beyond a single region: calling it multiple times adds more masks, it doesn't replace the previous one. Chain three PCAddMaskToCLIP nodes in sequence and you end up with three masks attached to the same CLIP, all addressable from your prompt - that's the intended pattern for building up a multi-region setup one mask at a time. (If you already know you want up to four masks, PCAddMaskToCLIPMany does the same thing in one node instead of daisy-chaining.)
Inputs and outputs
Required: clip. Optional: mask - a MASK. Output: CLIP, now carrying that mask for IMASK() to reference.
Installing it
ComfyUI Manager: search "ComfyUI Prompt Control", install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/asagi4/comfyui-prompt-control
No model downloads required by this node itself - you'll need whatever mask-producing tools you're already using (manual painting, SAM, a segmentation pack) to generate the MASK input in the first place; this node only handles attaching it.
Where people get tripped up
Order matters: this node has to run before the PCTextEncode/PCLazyTextEncode call that references the mask, and the CLIP that flows into your text-encode node needs to be the one that came out of this chain - feed the original, unmasked CLIP into your encoder by mistake and IMASK() will have nothing to find.
This pack's implementation of masked prompting is built on the same idea as BlenderNeko's original Cutoff technique - restricting part of a prompt's influence to a subset of the canvas or a subset of tokens - and it inherits the same real limitation the README flags for the related cutoff feature: this kind of masking doesn't work with models that use non-CLIP text encoders, like Flux. If you're on a fully LLM-encoded model, don't expect IMASK()-based regional prompting to do anything useful there - that's a documented gap, not a misconfiguration on your end.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| clip | CLIP | — | |
| maskopt | MASK | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| CLIP | CLIP | — |