Nodes/ComfyUI_RaykoStudio/๐ŸฆŠ RS Ref 2 Latent
ComfyUI Node

๐ŸฆŠ RS Ref 2 Latent

A reference image, injected straight into your conditioning

By RaykosanยทCreated about a year agoยทUpdated 5 days agoยท 79
๐ŸฆŠ RS Ref 2 Latent
  • vae
  • image
  • positive
  • negative
  • positive
  • negative
  • latent

RS Ref 2 Latent does exactly one thing, and the name says what it is: take a reference image, encode it into latent space with your VAE, and stuff those latents into both your positive and negative conditioning under the reference_latents key. It also passes the encoded latent out separately. If that sounds niche, it is - but it's a lightweight, dependency-free way to feed a reference image into reference-conditioned generation workflows.

How it works

The mechanism is short, and it's worth reading because it tells you what you're actually getting. The node reads the VAE's downscale_factor (8 for SD 1.5, SDXL, and Flux family VAEs), rounds your image's dimensions up to a multiple of that times 8 - so 64px for the common VAEs - upscales the image with Lanczos to fit, and trims to size. Then it runs the VAE encode and appends the resulting latent to your existing conditioning with conditioning_set_values(..., append=True), for both positive and negative.

Here's the honest part: whether the conditioning half does anything depends entirely on whether your model and sampler actually read a reference_latents entry. Many won't, and that's not a bug - the key is a convention some reference-conditioned pipelines and models honor, and the README frames it as compatible with "all VAE-based models" in the sense that it never breaks one. The universally useful output is the third one, latent: this node is essentially a VAE Encode with automatic size handling. If your model ignores reference latents, the positive/negative outputs pass through effectively unchanged and you've paid nothing extra - you got a correctly-sized latent out of an arbitrary-size image, which is itself handy for img2img-style samplers.

Inputs and outputs

  • vae (VAE) - your checkpoint's VAE. Required; it raises if you forget it.
  • image (IMAGE) - the reference image.
  • positive (CONDITIONING) and negative (CONDITIONING) - the conditioning from your CLIP encode nodes that the reference latents get attached to.
  • Outputs: positive, negative, and latent (LATENT). Wire latent into a sampler, or the modified conditioning into whatever your reference pipeline expects.

One thing to keep in mind: the auto-sizing rounds up to the 64px grid, so a 1000px reference becomes 1024px before encoding. That's a hair of upscaling, not a crop-and-resize - fine for references, and it's exactly what keeps the VAE happy.

Install

Standard pack install - one repo for every RS node. In ComfyUI Manager, search ComfyUI_RaykoStudio, or:

cd ComfyUI/custom_nodes
git clone https://github.com/Raykosan/ComfyUI_RaykoStudio.git

Restart after. No model files to download, no extra weights: this node is pure glue between the VAE, your image, and your conditioning.

Common issues

  • "VAE is required" error - you ran it without a VAE connected. Unlike some encode nodes, this one checks and refuses, so wire the VAE from your checkpoint loader first.
  • Output looks identical to your input workflow - if the model doesn't consume reference_latents, the conditioning is a no-op by design. Reach for the latent output and treat this as a smart VAE Encode, or check whether the model you're using actually supports reference conditioning before expecting style/identity transfer.
Category๐ŸฆŠ RaykoStudio

Inputs (4)

NameTypeDefaultDescription
vaeVAEโ€”
imageIMAGEโ€”
positiveCONDITIONINGโ€”
negativeCONDITIONINGโ€”

Outputs (3)

NameTypeDescription
positiveCONDITIONINGโ€”
negativeCONDITIONINGโ€”
latentLATENTโ€”