Any Latent Switch
Which latent feeds the sampler? Slot order decides
- latent_1
- latent
Any Latent Switch picks the first connected LATENT and feeds it to the latent output - decided by slot order, not a selector. In every image workflow there's a moment where the sampler needs "a latent", and there are usually several candidates for what that latent should be: a fresh empty latent at one resolution, an image encoded to latent, a latent carried from an earlier pass. This node is how you let the wiring choose.
It's the first-non-null switch pattern the community knows from rgthree's Any Switch, but typed: the sockets only accept LATENT, so there's no wildcard guessing and no way to plug an image in sideways.
How it works
Start with latent_1; wire another latent source and a latent_2 slot grows. At execution it collects every connected input that isn't None and returns the lowest-numbered live one. Muted and bypassed upstream nodes deliver None - and those get skipped - so muting the branch that supplies latent_1 hands the job to latent_2 automatically. Connect nothing and it raises "no inputs connected" rather than returning an empty latent dict.
Where you'd use it
- Empty vs. encoded. A fresh empty latent as the default, an img2img latent when you drop an image in.
- Multi-resolution presets. Two empty latents at different sizes, one sampler downstream, mute whichever you don't want.
- Pass routing. A latent from an earlier sampling stage vs. a fresh one for a refinement pass.
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, no pip dependencies - the pack is lean Python plus a bundled frontend and lives on the Comfy Registry under publisher tojioo.
Common issues
Slot order is the only real rule: a live latent_1 always beats latent_2, so if the sampler gets the "wrong" resolution, check the earlier slot's upstream for a mute or bypass - that's your switch. This node selects one latent; if you want to stack several latents into a single batch for batch generation, that's Any Latent Batch Switch instead. And keep a slot connected - an empty switch errors on the canvas rather than quietly returning nothing.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| latent_1opt | LATENT | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| latent | LATENT | — |