DP Image Empty Latent Switch SDXL
One node to flip between txt2img and img2img
- vae
- Image_Input
- Model
- Model_Ip_Adapter
- condition_positive
- condition_negative
- condition_positive_cn
- condition_negative_cn
- switch_settings
- MODEL
- condition_positive
- condition_negative
- LATENT
- denoise
Building a flexible SDXL workflow the normal way means a pile of manual reroutes: an empty latent for txt2img, a VAE-encoded latent for img2img, a switch to pick between them, another switch for whether ControlNet conditioning is active, another for IP-Adapter, and denoise wired differently depending on which path is live. This node is that whole switchboard collapsed into one box with three dropdowns. Set your mode, restart your sampler wiring once, and flipping between txt2img and img2img (with or without IP-Adapter, with or without ControlNet) becomes a dropdown change instead of a rewire.
How it works
Three mode toggles drive everything: Mode_Settings picks Txt2Image or Img2Img, IPadapter_Mode and ControlNet_mode turn those two branches on or off. Depending on what you've selected, the node decides what to hand back on its LATENT output - an empty latent sized to width/height for a fresh txt2img generation, or (when you're in Img2Img mode and have fed it an Image_Input) a latent derived from your source image instead. It does the same job for denoise: txt2img wants full denoise, img2img wants whatever your denoise_strength_img2img value is, and the node routes the right number out automatically instead of you remembering to change a KSampler's denoise field every time you switch modes.
The MODEL and conditioning outputs follow the same logic on the IP-Adapter and ControlNet toggles - feed the optional model/conditioning inputs for whichever branches you've turned on, and the node passes the appropriate ones through. This is the node's whole value proposition: it's a router, not a generator. It doesn't run IP-Adapter or ControlNet itself - think of it as the junction box that decides which of your pre-built branches gets used this run.
For context on what the ControlNet and IP-Adapter branches you're routing actually do: ControlNet conditions on spatial structure (edges, depth, pose - controlling where things go), while IP-Adapter conditions on semantic content from a reference image (controlling what things look like). They're complementary, not competing, and stacking both - IP-Adapter for style/identity, ControlNet for composition - is a long-standing SDXL workflow pattern. Note IP-Adapter has no Flux-era successor as an adapter, so this switch node's SDXL-specific framing matches where IP-Adapter still actually lives.
Inputs and outputs
Required:
Mode_Settings- Txt2Image or Img2Img.IPadapter_Mode- IPadapter_OFF or IPadapter_ON.ControlNet_mode- Controlnet_OFF or Controlnet_ON.width/height- 64 to 8192, default 1024 each. Used for the empty-latent path.denoise_strength_img2img- 0 to 1, default 1, only meaningful in Img2Img mode.
Optional (connect the ones your active toggles need):
vae,Image_Input- needed for Img2Img mode, to actually encode a source image into the latent.Model,Model_Ip_Adapter- your base model, and the IP-Adapter-patched model ifIPadapter_Modeis on.condition_positive/condition_negative- your base conditioning.condition_positive_cn/condition_negative_cn- the ControlNet-conditioned versions, used whenControlNet_modeis on.switch_settings- aSWITCH_SETTINGSinput, presumably from another DP switch/controller node in the pack, for chaining switch state.
Outputs: MODEL, condition_positive, condition_negative, LATENT, and denoise (FLOAT) - this last one is the piece that makes the node genuinely save wiring, since you can plug it straight into a KSampler's denoise input and never touch that field again when switching modes.
How to install it
Search ComfyUI-Desert-Pixel-Nodes in ComfyUI Manager, or:
cd ComfyUI/custom_nodes
git clone https://github.com/DesertPixelAi/ComfyUI-Desert-Pixel-Nodes
Restart ComfyUI, find it under DP/utils. No models to download for the node itself - it's a router, so it's only as useful as the SDXL checkpoint, VAE, ControlNet, and IP-Adapter models you feed it from elsewhere in your graph.
Common issues & troubleshooting
Img2Img mode does nothing / errors. Check that Image_Input and vae are both actually connected - Img2Img mode needs both to encode a source image into a latent. If either is missing, there's nothing for the node to base the img2img latent on.
IPadapter_Mode is ON but nothing changes. Make sure Model_Ip_Adapter (the pre-patched model) is connected - the toggle picks which model output gets routed, it doesn't run IP-Adapter patching itself. You still need an actual IP-Adapter apply node earlier in the graph feeding this input.
ControlNet toggle is on but conditioning looks unchanged. Same idea: condition_positive_cn/condition_negative_cn need to be wired from wherever you're actually applying ControlNet upstream. This node routes between the plain and ControlNet-conditioned pairs; it doesn't apply ControlNet itself.
Denoise seems stuck at 1.0 in Img2Img mode. Confirm you're reading the node's denoise output into your sampler rather than a hardcoded value left over from before - that's the entire point of the output, and it's easy to have an old manually-set denoise value still wired in from before you added this switch.
Inputs (15)
| Name | Type | Default | Description |
|---|---|---|---|
| Mode_Settings | COMBO | Txt2Image | 2 options: Txt2Image, Img2Img |
| IPadapter_Mode | COMBO | IPadapter_OFF | 2 options: IPadapter_OFF, IPadapter_ON |
| ControlNet_mode | COMBO | Controlnet_OFF | 2 options: Controlnet_OFF, Controlnet_ON |
| width | INT | 102464–8192 | — |
| height | INT | 102464–8192 | — |
| denoise_strength_img2img | FLOAT | 1.000–1 | — |
| vaeopt | VAE | — | |
| Image_Inputopt | IMAGE | — | |
| Modelopt | MODEL | — | |
| Model_Ip_Adapteropt | MODEL | — | |
| condition_positiveopt | CONDITIONING | — | |
| condition_negativeopt | CONDITIONING | — | |
| condition_positive_cnopt | CONDITIONING | — | |
| condition_negative_cnopt | CONDITIONING | — | |
| switch_settingsopt | SWITCH_SETTINGS | — |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| MODEL | MODEL | — |
| condition_positive | CONDITIONING | — |
| condition_negative | CONDITIONING | — |
| LATENT | LATENT | — |
| denoise | FLOAT | — |