Nodes/bsz-cui-extras/BSZ Latent RGBA Image
ComfyUI Node

BSZ Latent RGBA Image

Encode a solid color into a latent with your own VAE

By Beinsezii·Created 3 years ago·Updated 2 years ago· 27
BSZ Latent RGBA Image
  • vae
  • LATENT
r0.00
g0.00
b0.00
a0.50
width1024
height1024
batch_size1

The pack's other colored-latent node, BSZ Colored Latent Image XL, gives you eight fixed colors with hardcoded constants. BSZ Latent RGBA Image gives you any color - red, green, blue channels plus an alpha for how strongly the color saturates the latent - by actually encoding a solid-color image with the VAE of your choice. It costs a VAE encode, and it buys you infinite palette.

Why you'd reach for it

You want to start a generation from a specific tint, or you're building the "injection" latent for the pack's experimental sampler and you want a precise color rather than one of the eight presets. Because it encodes through whatever VAE you provide, it also works on models where the hardcoded preset node doesn't - you're not locked to SDXL's baked-in constants.

Inputs

  • vae - the VAE used to encode the color into latent space. Use the one matching your checkpoint.
  • r, g, b - color channels, each 0.0 to 1.0.
  • a - alpha, 0.0 to 1.0. Zero produces an all-zero (empty) latent; 1.0 is a fully saturated color latent.
  • width, height, batch_size - size and count, same as EmptyLatentImage.

Output: a LATENT.

How it works

The node builds a full-size image where every pixel is your RGB color, VAE-encodes it, scales the latent by a, and expands it to your batch size. If a is below 0.01 it short-circuits and returns a plain zero latent, so you can drive alpha down to "empty" without paying the encode cost. That's the mechanism - a real encode of a real (solid) image, not hardcoded channel values.

The trap the README warns about

Don't assume 0.5, 0.5, 0.5 with alpha 0 equals an empty latent - the author calls it out explicitly: "even though 0.5, 0.5, 0.5 seems like it should be equal to an empty latent, in reality it is not and seeds will be very different." Mid-gray is not the same as the VAE's actual latent-space zero point. If you want a clean empty latent, use a = 0 (which returns true zeros) or stock EmptyLatentImage.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/Beinsezii/bsz-cui-extras

then restart, or install via ComfyUI Manager. Pure Python, no dependencies - the only "dependency" is a VAE, which you already have. Pair it with the HSVA flavor if you think in hue/saturation/value instead of RGB; the two share everything but the input sliders.

Categorybeinsezii/latent

Inputs (8)

NameTypeDefaultDescription
vaeVAE
rFLOAT0.000–1
gFLOAT0.000–1
bFLOAT0.000–1
aFLOAT0.500–1
widthINT102416–16384
heightINT102416–16384
batch_sizeINT11–4096

Outputs (1)

NameTypeDescription
LATENTLATENT