WanVaceRefsToContextWindows
Give each context window its own reference image
- positive
- negative
- vae
- reference_images
- positive
- negative
Long Wan generations don't happen in one pass - you slice the clip into context windows, generate each window, and stitch them together, usually with Kijai's WanContextWindowsManual nodes. That works fine until your video crosses scenes: the character reference that was right for window 0 is wrong for window 5, and identity drifts because every window is pulling from the same stale reference. WanVaceWindowReferences is the pack's answer: you hand it a batch of reference images and it hands each context window the right one, round-robin style, encoded straight into the conditioning so the windowing hook can use it per-window.
How it works
The node takes your reference_images batch and encodes every image through the VAE into the 32-channel reference format VACE expects (16 real latent channels + 16 zeros), resized to your width/height first. Those encoded references, plus a strength list and an optional explicit mapping, are stored in the conditioning under keys like window_reference_batch. Then the pack's context-window callback picks the correct reference for each window as it's processed:
- Default behavior: 1:1 mapping - window 0 gets ref 0, window 1 gets ref 1, and if you run out of references, extra windows repeat the last one.
explicit_ref_mapping: if you want more control, type a string like0,1,2,1,0- that maps ref 0 to window 0, ref 1 to windows 1 and 3, ref 2 to window 2, and so on. "More windows than entries? repeat last" is the rule.ref_strengths: a single float applies to all references; wire a float list in for per-reference strength control.
Required inputs are positive, negative, vae, and reference_images; optional are width/height (defaults 832×480, images resized to match) plus the two above. Outputs are just positive and negative - same conditioning, enriched.
Where it fits
This is a long-video node, full stop. Its habitat is the README's context-window workflow: branch your conditioning into two WanContextWindowsManual stages (high-noise and low-noise passes), and drop this node ahead of them so each window carries its own identity reference. It pairs naturally with WanMaskToLatentSpace in that same workflow - the README explicitly calls that node out for keeping fast-motion masks sharp before they flow through the windows. If you're doing 81-frame single-shot clips, this node is overkill; keep it for multi-scene takes where a single reference can't cover the whole video.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/drozbay/ComfyUI-WanVaceAdvanced
# restart ComfyUI
or ComfyUI Manager → "ComfyUI-WanVaceAdvanced". Deps are numpy + scipy; you'll need Kijai's WanVideoWrapper (or equivalent) for the WanContextWindowsManual nodes this is designed to work with. One honest warning: per-window references on a multi-scene video is exactly the kind of thing that sounds magical and needs real tuning - keep your reference images simple, put the subject in the focus, and expect to iterate on the mapping string before it sings.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| positive | CONDITIONING | — | |
| negative | CONDITIONING | — | |
| vae | VAE | — | |
| reference_images | IMAGE | — | |
| widthopt | INT | 83216–16384 | Target width for reference images. Images will be resized to match. |
| heightopt | INT | 48016–16384 | Target height for reference images. Images will be resized to match. |
| ref_strengthsopt | FLOAT | 1.000–10 | Per-reference strength. Can be a single value (applies to all) or connect a list of floats for per-reference control. |
| explicit_ref_mappingopt | STRING | Explicit mapping of references to windows. Format: '0,1,2,1,0' maps ref[0] to window 0, ref[1] to window 1, etc. If empty, uses 1:1 mapping. Extra windows repeat last entry. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| positive | CONDITIONING | — |
| negative | CONDITIONING | — |