Ref Image Encode
One prompt, up to ten reference images — this node is the whole multi-ref encode pipeline
- clip
- vae
- image1
- image2
- image3
- image4
- image5
- image6
- image7
- image8
- image9
- image10
- conditioning
- latent
You've got a reference image - a character, a product shot, a scene - and you want to hand it to an edit model like Flux 2 Klein or Qwen-Image-Edit and get a modified version back. Normally that means a pile of nodes: a CLIP Encode with a vision-language model, a VAE Encode for the reference, and some glue to tell the model "look at these pictures while you read this prompt." Ref Image Encode collapses that whole block into one node. Feed it up to ten images and a single instruction, and it hands back the conditioning and the reference latent, ready for the KSampler.
It's the marquee node of the Toggle-Pass pack, and it's aimed squarely at the workflow that has basically taken over character consistency since late 2025: instruction editing rather than IP-Adapter or ControlNet scaffolding (the modidex KB frames exactly this shift). If you're building a "one reference, many edits" graph on a modern model, this is the node that does the plumbing for you.
How it works
Under the hood it does the two-encoder dance that edit models expect. Each reference image gets VAE-encoded into a latent (resized to your output size first), and those latents are attached to the conditioning as reference_latents - that's the "appearance" channel. The same images get downscaled to roughly 384×384 and passed to the CLIP tokenizer as images=, which is the "semantics" channel: the vision-language text encoder actually sees the picture while it reads your prompt. No manual <|vision_start|> tokens, the tokenizer inserts those itself.
A couple of settings matter here, and they're labeled in Chinese in the node UI:
- 模型类型 (Model type):
Flux2,Qwen Layered, orSD / SDXL. This decides the latent geometry - Flux2 uses /16 spatial scaling, SD/SDXL uses /8. Pick the one that matches the model you're actually sampling, or your latent shape won't line up. - 匹配原图尺寸 (Match source size): ON uses the actual image dimensions; OFF uses 输出宽度/输出高度 (output width/height).
- 图层数 (Layer count): only appears in
Qwen Layeredmode, and it's the interesting one. That mode outputs a 5D layered latent of shape[1, 16, layers+1, h/8, w/8]which you wire straight into the KSampler's latent input - it replaces a dedicatedEmptyQwenImageLayeredLatentImagenode, saving you a node and a size-matching headache.
Inputs and outputs that matter
Required inputs: clip (a vision-language CLIP, see below), vae, num_images (1–10, this controls how many image1–imageN slots appear), prompt, and instruction (the system prompt - the default is tuned for Qwen-Image-Edit-style models, so edit it if your model expects different framing).
Outputs: one conditioning and one latent. The conditioning goes to the KSampler's positive input; the latent is the reference latent from the first image, so for img2img-style editing you feed that to the sampler's latent input instead of an Empty Latent.
The gotcha that bites people
This node needs a CLIP that can actually take images - Qwen2.5-VL or the Qwen3-4B that ships with Flux 2 Klein. Hook up a plain SD CLIP and clip.tokenize(images=...) will fail. The README says it plainly: requires Qwen2.5-VL or compatible. And grow num_images before you wire things up - adding slots is safe, but shrinking removes slots from the top, so a wire on the last slot will get dropped.
Installing it
The whole pack installs as one:
cd ComfyUI/custom_nodes
git clone https://github.com/electricty00/ComfyUI-Toggle-Pass
then restart ComfyUI. Or use ComfyUI Manager and search for ComfyUI-Toggle-Pass. There's no requirements.txt - the only dependencies are the ones ComfyUI already ships (torch, PIL, numpy), so this is one of the rare custom nodes that can't break your environment. The pack is a small personal project with essentially no community footprint yet, so expect the polish of a node built for its author's own workflows rather than a big open-source project.
Inputs (20)
| Name | Type | Default | Description |
|---|---|---|---|
| clip | CLIP | — | |
| vae | VAE | — | |
| num_images | INT | 11–10 | — |
| prompt | STRING | — | |
| instruction | STRING | Describe the key features of the input image (color, shape, size, texture, objects, background), then explain how the user's text instruction should alter or modify the image. Generate a new image that meets the user's requirements while maintaining consistency with the original input where appropriate. | — |
| image1opt | IMAGE | — | |
| image2opt | IMAGE | — | |
| image3opt | IMAGE | — | |
| image4opt | IMAGE | — | |
| image5opt | IMAGE | — | |
| image6opt | IMAGE | — | |
| image7opt | IMAGE | — | |
| image8opt | IMAGE | — | |
| image9opt | IMAGE | — | |
| image10opt | IMAGE | — | |
| 模型类型opt | COMBO | Flux2 | 3 options: Flux2, Qwen Layered, SD / SDXL |
| 匹配原图尺寸opt | COMBO | OFF | 2 options: OFF, ON |
| 输出宽度opt | INT | 1024256–4096 | — |
| 输出高度opt | INT | 1024256–4096 | — |
| 图层数opt | INT | 31–64 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| conditioning | CONDITIONING | — |
| latent | LATENT | — |