Nodes/Tojioo Passthrough/Any Mask Switch
ComfyUI Node

Any Mask Switch

Pick between mask sources by which one is connected first

By Tojioo·Created 11 months ago·Updated 7 months ago· 13
Any Mask Switch
  • mask_1
  • mask

Any Mask Switch returns the first connected MASK from its inputs, chosen by slot order, and hands it to the mask output. If you've got two ways of producing a mask - an auto-segmenter and a manual paint, say - you've got exactly the use case this node exists for: one consumer downstream, whichever mask source is live feeds it.

It's the fallback-switch pattern the community uses everywhere, the same "first non-null input wins" shape rgthree popularized with Any Switch. Tojioo's version is typed to MASK rather than a wildcard socket, which means the input won't accept anything that isn't a mask and the output is self-documenting.

How it works

One socket, mask_1, to start; each new mask source you wire grows another slot - mask_2, mask_3, and so on. On each run it collects the inputs that aren't None and returns the lowest-numbered connected one. The None skip is the feature, not a quirk: muted or bypassed upstream nodes deliver None, so muting the branch feeding mask_1 automatically hands the job to mask_2. Connect no inputs and the node raises a "no inputs connected" error rather than returning a blank mask.

Where you'd use it

  • Segmenter A vs. segmenter B. Run two segmentation approaches, mute one, keep the same mask-combine or inpaint node wired.
  • Manual vs. automatic masks. A painted mask for the shots you care about, an auto mask as fallback.
  • Fallback routing. Preferred source first, fallback second, graph decides itself.

Install

ComfyUI Manager → search "Tojioo Passthrough" → install, or:

cd ComfyUI/custom_nodes
git clone https://github.com/Tojioo/tojioo_passthrough.git

Restart ComfyUI. No models or pip dependencies - the pack is Python plus a bundled frontend and is on the Comfy Registry under publisher tojioo.

Common issues

Slot order is the whole rule: a live mask_1 always wins over mask_2, so a "wrong" mask means the earlier slot's upstream is muted, bypassed, or unwired - muting is your switch. This node selects a single mask; if your goal is stacking several masks into one batch, grab Any Mask Batch Switch from the same pack instead. And keep at least one slot connected, or the node errors on you - loudly, which is better than a silent blank.

CategoryTojioo Passthrough/Dynamic Nodes/Switch Nodes

Inputs (1)

NameTypeDefaultDescription
mask_1optMASK

Outputs (1)

NameTypeDescription
maskMASK