Nodes/Diffusion CG/Diffusion CG
ComfyUI Node

Diffusion CG

Color grading done inside the sampler, not in post

By Haoming02·Created 3 years ago·Updated 9 months ago· 103
Diffusion CG
  • latent
  • LATENT
recenter0.00
normalization0.00

Your image comes out with a grey wash, or the opposite - a "richly coloured haze" where a checkpoint's bias tints everything. Most people reach for a different VAE or a post-processing filter. The first is the wrong lever and the second smears detail. Diffusion CG fixes the color while the image is being drawn, in latent space, which is where the problem actually lives.

This is the flagship node of the Haoming02/comfyui-diffusion-cg pack ("ComfyUI Diffusion Color Grading"), by Haoming02 - the same author behind the sd-webui-diffusion-cg extension for A1111 and the well-known Resharpen node - described as joint research with TimothyAlexisVass. The whole idea: a neutral, balanced image isn't something you paint on afterward, it's something you sample toward. Diffusion CG does two kinds of nudging during generation, and it does them in the latent, so detail survives.

How it works

Attach it between Empty Latent and KSampler. It passes the latent through untouched - the node's real job is to set two global numbers and then monkey-patch ComfyUI's sampling preview callback. At each denoise step it grabs the predicted clean latent (x0) and applies two adjustments:

  • recenter pulls each latent channel's mean toward neutral, weighted by how much that channel varies relative to the batch. A color cast shows up as channel means sitting away from the neutral point, so this is the "kill the tint" knob.
  • normalization rescales each channel's dynamic range toward a target magnitude, so a channel that's spread too wide or too narrow stops dominating the image. This is the "vibrant and contrasty" part.

One neat detail in the code: the effect is strongest at the start of denoising and fades to zero by the final step. The node nudges the early composition, then gets out of the way while detail locks in. That's why it reads as a color grade rather than as a weird glitch.

The inputs that matter

  • latent - wire from Empty Latent (or the LATENT output of whatever precedes sampling).
  • recenter - 0 to 1, default 0. How hard to pull channel means toward neutral. Leave at 0 and nothing happens.
  • normalization - 0 to 1, default 0. How hard to force channels toward a normal dynamic range. The default 0.0 means the node is inert until you raise either slider.

Output is a single LATENT, wired straight into your KSampler's latent_image. Nothing else changes in the workflow.

Install

Two standard ways, no hidden extras:

# ComfyUI Manager → "Install Custom Nodes" → search "Diffusion CG"

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

Then restart ComfyUI. This pack is refreshingly light: zero Python dependencies (its pyproject.toml declares an empty list) and no model files to download. There's nothing here that can fight with your other nodes.

Common issues

  • "Does not work with certain samplers." The author says this plainly in the README. Because the effect rides on the sampler's callback, some samplers - the author's issue tracker names LCM-style and SD Turbo setups - don't route through it the same way. If you see no effect, try a plain KSampler with euler or dpmpp_2m before blaming your VAE.
  • The effect is global. Diffusion CG sets module-level state, so it applies to every sampling pass in the run. That's why the pack ships Disable CG - drop it inline before a hires-fix pass to reset the values to 0. The pack also resets everything when it validates a prompt that contains no Diffusion CG node, so a fresh workflow won't inherit your old settings.
  • Don't chase this if your real problem is a mismatched VAE. If the model can't decode the latent, no color node fixes that (see the KB's VAE notes on grey washed-out output).

The takeaway: if your output has a consistent cast or a blown-out, mushy look that post-processing can't clean without ruining detail, this is one of the few tools that fixes the cause instead of the symptom. Start with recenter around 0.5 and normalization around 0.5, then dial to taste.

Categorysampling

Inputs (3)

NameTypeDefaultDescription
latentLATENT
recenterFLOAT0.000–1
normalizationFLOAT0.000–1

Outputs (1)

NameTypeDescription
LATENTLATENT