Nodes/ComfyUI-TextureAlchemy/Mask Compositor (Interactive)
ComfyUI Node

Mask Compositor (Interactive)

Paint masks directly on your texture, right in the node

By amtarr·Created 9 months ago·Updated 4 months ago· 58
Mask Compositor (Interactive)
  • image
  • image
  • mask
  • mask_preview

Here's the workflow friction that never gets a dedicated solution: you need a mask, but you don't have a segmenter, and drawing one in an external editor means round-tripping files and praying the coordinates line up. Mask Compositor attacks that directly - it's an interactive canvas editor embedded in the node. You load an image, click a button to open a paint UI right in the ComfyUI graph, brush a mask over the actual image, save it back into the node, and out the other side comes a proper MASK tensor plus a preview. No external editor, no coordinate guessing.

It's one of the genuinely interactive nodes in TextureAlchemy (the pack's Texture Alchemist/Masks category), and it's the kind of thing that only exists because custom node authors can ship a web widget alongside their Python - the front-end lives in the pack's web/mask_compositor.js.

How it works

The node itself is thin. It takes an image, accepts a hidden mask_data string that the web widget fills in, and parses that JSON into a mask array when you hit save in the editor. The heavy lifting - the painting canvas, brush, erasing, undo, whatever the widget offers - happens in your browser via the bundled JavaScript, overlaid on the actual image so you're drawing on top of what you're masking. When you're done, the painted RGBA data is serialized back, reshaped to the image dimensions, and emitted as a real ComfyUI mask.

The outputs are exactly what a mask workflow needs:

  • image - the original, passed through (so the node can sit inline without breaking the graph).
  • mask - the MASK tensor you painted, ready to wire into inpaint, compositing, or blend nodes.
  • mask_preview - an IMAGE version of the mask so you can see it in the usual preview node.

How you use it

Add the node, connect an image, and look for the button in the node UI that opens the mask editor - the flow is "Open Mask Editor → paint → Save to Node," per the source docstring. Mask over the parts you want selected (or background you want excluded, depending on how you're feeding it downstream). Then wire mask into whatever needs it.

The pain point to plan around: it's interactive by nature, so it doesn't "just run" headlessly. You paint, the widget stores the data, and the node converts it on the next queue run. That's the intended loop.

Installing it

Ships with ComfyUI-TextureAlchemy. ComfyUI Manager → search "TextureAlchemy" → install → restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/amtarr/ComfyUI-TextureAlchemy

Restart and find it under Texture Alchemist → Masks. No extra pip packages, no model downloads. The interactive widget only works in the browser UI - if you're driving ComfyUI purely from the API, this node won't have much for you.

Common issues

  • "The editor won't open." It's a web widget, so a stale browser cache or an old ComfyUI frontend can hide it. Hard-refresh (Ctrl/Cmd+Shift+R) and make sure the pack's web/ folder is intact.
  • "My mask is inverted when I use it downstream." The node outputs what you painted; whether your downstream node expects white=selected or white=background is its business. Flip with an invert node if needed - the pack's other mask tools can do that.
  • "The mask resolution is off." The widget saves at the image's dimensions; if you've resized the image after painting, repaint or resize the mask to match.

It's a convenience node - nothing you couldn't do in an editor and re-import - but the convenience is the point. For quick texture-region masks mid-workflow, it saves you the round trip and the inevitable "did I export at the right resolution" panic.

CategoryTexture Alchemist/Masks

Inputs (1)

NameTypeDefaultDescription
imageIMAGE

Outputs (3)

NameTypeDescription
imageIMAGE
maskMASK
mask_previewIMAGE