Nodes/ComfyUI_EmAySee_CustomNodes/EmAySee Latent Switch
ComfyUI Node

EmAySee Latent Switch

The latent switch that isn't a switch — it's a priority override

By EmAySee·Created about a year ago·Updated 4 months ago· 2
EmAySee Latent Switch
  • top_latent
  • bottom_latent
  • selected_latent

Don't expect a dropdown

Most "switch" nodes in ComfyUI give you a selector widget and a stack of inputs. EmAySee_LatentSwitch is not that. It has no selector at all - instead it encodes a simple rule: if bottom_latent is connected, that's the output; otherwise top_latent is. Think of it less as a switch and more as an override port. You wire your normal latent into top_latent, and whatever you plug into bottom_latent takes priority whenever it's present.

That pattern is quietly useful. Say you have a standard txt2img branch feeding a sampler, but you occasionally want to run an img2img or inpaint branch instead. Connect the usual latent to top_latent, the alternate branch to bottom_latent, and toggling which branch is active is just a matter of connecting/disconnecting one wire - or driving the bottom from an upstream switch that conditionally emits. ComfyUI treats an unconnected optional input as None, which is exactly what the node checks for, so this composes cleanly with other nodes that emit or withhold latents.

How it works

The whole implementation is a two-line check: if bottom_latent is not None, return it; else return top_latent. That's the entire mechanism - no merging, no blending, no interpolation. It's a pure passthrough of whichever latent wins. There's nothing clever to break, which is honestly the appeal.

Inputs and outputs

  • top_latent (LATENT) - required. Your default/fallback latent.
  • bottom_latent (LATENT) - optional. The override; wins whenever it's connected.

Output: selected_latent (LATENT) - whatever won the priority contest, ready for a KSampler, VAE decode, or latent blend node.

Install

From the ComfyUI_EmAySee_CustomNodes pack:

cd ComfyUI/custom_nodes
git clone https://github.com/EmAySee/ComfyUI_EmAySee_CustomNodes
# restart ComfyUI

Or ComfyUI Manager → "ComfyUI_EmAySee_CustomNodes". No extra dependencies; the pack ships with no requirements.txt. Expect the SPECTRE banner on load.

Gotchas

The main trap is expecting a runtime toggle. If you want to flip between two latents at runtime based on a seed or a boolean, this node won't do it on its own - it has no control input, and connecting bottom_latent is a graph-editing action, not a per-run choice. For genuine runtime switching, you want a selector-style node (the rgthree pack's switches, or ComfyUI's built-in Latent Batch/LatentSwitch equivalents) where an INT widget picks the branch. Where EmAySee_LatentSwitch shines is the fixed-priority pattern: a guaranteed default with an optional override. Also note both latents are passed through unwrapped - a LATENT in this pack is the standard dict, so anything that consumes core sampler latents works here.

CategoryEmAySee/Utils

Inputs (2)

NameTypeDefaultDescription
top_latentLATENT
bottom_latentoptLATENT

Outputs (1)

NameTypeDescription
selected_latentLATENT