Nodes/Diffusion CG/RecenterXL
ComfyUI Node

RecenterXL

SDXL's YCbCr recenter — color grading without touching the sampler

By Haoming02·Created 3 years ago·Updated 9 months ago· 103
RecenterXL
  • latent
  • LATENT
strength0.00
Y0.00
Cb0.00
Cr0.00

The Recenter XL node (UI name RecenterXL) is the SDXL edition of the pack's latent-recentering trick, and it's the one that makes the global-hook approach feel worth it. You keep your normal KSampler, drop this little node on the latent wire, and every sampling pass pulls its channel means toward neutral - killing the color cast while the image is still being drawn.

The interesting bit is how it models color for SDXL. Where the SD 1.5 Recenter node gives you four C/M/Y/K targets, this one gives you Y, Cb, and Cr - the luma-plus-two-chrominance axes of YCbCr. Same idea as the author's Lab-style L/a/b controls on the sampler-based XL node, but a different flavor of the color space. It's a reminder that the latent channels aren't literally RGB; the author is choosing a color model that maps onto them sensibly and exposing the axes as sliders.

How it works

Same mechanism as its sibling: the node is a pass-through that stores target means and an effect strength in a global, then wraps ComfyUI's sampling functions. At each step of the sample:

x[channel] += (target[channel] - x[channel].mean()) * strength

The internal mapping is [Y, -Cr, -Cb] - note the signs on the two chroma axes, so raising "a warm axis" actually shifts it the intended direction. You don't need to hold that in your head; just know the three sliders steer luma and the two color-opponent axes.

The inputs that matter

  • latent - from Empty Latent or anything upstream of a KSampler.
  • strength - 0 to 1, default 0. Effect volume; 0 = nothing happens.
  • Y (default 0) - target mean for the luma-ish channel. Pulling this affects overall brightness balance.
  • Cb (default 0), Cr (default 0) - target means for the two color axes. Start from 0 (neutral) and bias the one that matches your cast.

Output: LATENT, straight into your KSampler.

The catch, same as always

This node inherits every global-state quirk of the pack's hook design:

  • The effect applies to all sampling passes in the run, not just the one you meant. A hires-fix second pass will get re-graded unless you add a Recenter/Recenter XL with strength 0 afterward to reset it.
  • Partial reruns are the classic trap: if ComfyUI only re-executes part of the graph, the Recenter node doesn't re-run and the global can be stale, so colors change for no obvious reason after you edit a cached node.
  • Not every sampler plays ball. The pack's known issue ("does not work with certain samplers") applies, and low-step/distilled samplers (LCM, Turbo) are the usual no-shows.

A note on versions

This is from the middle era of the pack. The current v2 rewrite replaced the standalone Recenter/Recenter XL nodes with the single Diffusion CG node (recenter + normalization, works for both SD 1.5 and SDXL) plus Disable CG as the reset. If you install today and only find those two, you're looking at the redesign - use Diffusion CG instead.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/Haoming02/comfyui-diffusion-cg

Restart ComfyUI. No dependencies, no models, no fuss.

Categorylatent

Inputs (5)

NameTypeDefaultDescription
latentLATENT
strengthFLOAT0.000–1
YFLOAT0.00-1–1
CbFLOAT0.00-1–1
CrFLOAT0.00-1–1

Outputs (1)

NameTypeDescription
LATENTLATENT