Nodes/Diffusion CG/KSampler (Recenter)
ComfyUI Node

KSampler (Recenter)

A KSampler that pulls color back to neutral while it samples

By Haoming02·Created 3 years ago·Updated 9 months ago· 103
KSampler (Recenter)
  • model
  • positive
  • negative
  • latent_image
  • LATENT
seed0
steps20
cfg8.0
sampler_name
scheduler
denoise1.00
strength0.0
C0.0126
M0.5152
Y-0.1278
K0.00

Some checkpoints have a personality. They're sharp, they're fast, and they push every image into a warm haze or a greenish cast. You can fix it with a VAE swap, or you can fix it in post - but the cleanest fix is to stop the drift at the source. Center Sampler (shown in the UI as KSampler (Recenter)) is a drop-in replacement for the normal KSampler that recenters the latent channels during sampling, pushing your output toward a neutral, balanced, and contrasty color. No second pass, no filter.

It's the flagship node of the early Haoming02/comfyui-diffusion-cg ("Diffusion CG") pack - the ComfyUI port of the author's sd-webui-diffusion-cg extension for A1111.

How it works

A normal diffusion run takes a latent of pure noise and refines it step by step. This node does the same loop as ComfyUI's KSampler - same samplers, same schedulers - but it wraps the sampling callback. At each step, before the model's output is handed back, it recenters each of the 4 latent channels toward a target mean:

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

Pull the mean of a channel up or down and you shift the color balance of the final image, because a cast is exactly that: channel means sitting off the neutral point. The C, M, Y, K inputs are your target means (loosely named after CMYK as a color metaphor - they are not real CMYK percentages, a confusion the author's issue tracker has fielded before).

The inputs that matter

Everything a KSampler has: model, seed, steps, cfg, sampler_name (the full ComfyUI list), scheduler, positive, negative, latent_image, denoise. Then the extras:

  • strength - 0 to 1, default 0. How hard the recenter effect bites. Zero = the node behaves like a plain KSampler.
  • C (default 0.0126), M (default 0.5152), Y (-0.1278), K (0) - the target mean for each channel. The defaults are the author's empirically-derived values for what a neutral SD 1.5 image's channels should sit at. Raising strength with the defaults running gives you the "kill the cast" effect; tweaking individual values steers color by hand.

Output is a single LATENT, wired to VAE Decode exactly like a normal KSampler's.

A note on versions

Center Sampler is from the early era of this pack. The current v2 rewrite dropped the standalone sampler nodes in favor of the single Diffusion CG node (which applies recenter + normalization to whatever KSampler you already have, so you keep your own sampler and scheduling choices). If you install the pack today and can't find Center Sampler, that's why - use Diffusion CG instead, or pin an older release of the pack if you specifically want this all-in-one sampler.

Install

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

Restart ComfyUI. Zero dependencies, no model downloads.

Gotchas

  • Not all samplers work. The pack's README warns about this, and the issue tracker confirms LCM-style / Turbo-style setups are the usual offenders. If you see no recentering effect, switch sampler.
  • Because it's a full KSampler replacement, you lose nothing - but you also inherit whatever sampler/scheduler combo you pick, so set them deliberately rather than leaving euler in by default.
Categorysampling

Inputs (15)

NameTypeDefaultDescription
modelMODEL
seedINT00–18446744073709550000
stepsINT201–10000
cfgFLOAT8.00–100
sampler_nameCOMBO22 options: euler, euler_ancestral, heun, heunpp2, dpm_2, dpm_2_ancestral, +16
schedulerCOMBO6 options: normal, karras, exponential, sgm_uniform, simple, ddim_uniform
positiveCONDITIONING
negativeCONDITIONING
latent_imageLATENT
denoiseFLOAT1.000–1
strengthFLOAT0.00–1
CFLOAT0.0126-1–1
MFLOAT0.5152-1–1
YFLOAT-0.1278-1–1
KFLOAT0.00-1–1

Outputs (1)

NameTypeDescription
LATENTLATENT