Nodes/CFG Megapack/Reinhard tonemap of the guidance (ComfyUI)
ComfyUI Node

Reinhard tonemap of the guidance (ComfyUI)

A soft clip for when high cfg starts to glow

By AbstractEyes·Created 5 days ago·Updated 5 days ago· 3
Reinhard tonemap of the guidance (ComfyUI)
  • model
  • MODEL
◄scale-1.0►
◄multiplier1.0►
◄spaceauto (the method's own)►

Photographers have known since 2002 that you don't clamp highlights, you compress them. Reinhard's tone mapping curve is the simplest version: m / (m + 1). Small values sail through almost untouched, big values squash toward a ceiling instead of hitting it and flattening.

ComfyUI's own codebase already contains that as a latent operation - LatentOperationTonemapReinhard, wired up by LatentApplyOperationCFG. This node is that operation promoted to a proper guidance rule, with the ceiling exposed as a knob. It's the gentlest member of the "correction" family, and the one that's least likely to make your image look like it went through a filter.

How it works

Same start as everything here: plain CFG, u + w (c - u). Then it looks at the guidance difference g = c - u per pixel.

  1. Take each pixel's magnitude m - the length of its channel vector in g.
  2. Compute a ceiling for the image: top = multiplier * (mean(m) + 5 * std(m)).
  3. Tone-map: m' = top * (m / top) / (m / top + 1).
  4. Rescale each pixel's vector to the new magnitude and rebuild: x0 = u + w * g'.

Because the ceiling is derived from the image's own statistics, it adapts per frame instead of being a fixed number you have to hand-tune per prompt. Pixels where guidance pushes hard get compressed; pixels where it barely pushes are essentially unchanged. No clipping edge, no channel-wise surgery - which is why it preserves texture better than a per-image rescale does.

Inputs and output

  • model - loader → node → sampler.
  • scale - the w this rule uses; -1 means "the sampler's cfg", which is right unless you're deliberately evaluating a different scale.
  • multiplier - default 1.0, and it "raises the ceiling (large = plain CFG)". This is the whole node in one number. Higher means the ceiling sits further out, so fewer pixels get compressed; crank it to something silly and you've rebuilt plain CFG. Lower and you get soft, hazy highlights.
  • space - left on auto (the method's own). The rule is nonlinear, so which space it runs in changes the image; the tooltip in ComfyUI explains the auto behaviour.

Output: a MODEL, so it slots between the checkpoint loader and your KSampler like any other model patch. Neutral settings reproduce plain sampling exactly, which makes A/B testing painless.

Install

Manager → search CFG Megapack → install, restart. Manual install:

cd ComfyUI/custom_nodes
git clone https://github.com/AbstractEyes/comfy-cfg-megapack

Nothing else to fetch - no requirements.txt, no model files, no API keys. The pack's one hard requirement is a recent ComfyUI, since it's written against comfy_api.latest (the README reports testing on 0.38.0).

Where people get burned

Nothing happened. Almost always the single CFG-function slot: another pack's RescaleCFG, Mahiro or RenormCFG node is chained after this one and has taken the slot. Reorder, or remove it. The pack ships CFG Plan Readout precisely so you can see which rule actually ended up installed.

It's subtle by design. If you want a visible "cfg 15 that looks like cfg 7" transformation, this isn't that - Go with a standard-deviation rescale at phi 0.7 (the Guidance Rescale node in the same folder), or one of the projection rules like APG. Reinhard keeps more of the high-scale look; the rescale family flattens it.

multiplier below 1 on a low-cfg run. At cfg 5–7 there's not much magnitude to tone-map, so winding the multiplier down mostly buys you a soft, slightly milky image and nothing else. This node earns its keep at cfg 10+.

The order of corrections. In this pack, correction-type nodes stack in the order you chain them rather than replacing each other - so Reinhard after a rescale is a different image from rescale after Reinhard. If you stack them, expect to iterate; one of the two is usually enough.

Start with multiplier 1.0, dial to 1.5 if the image looks restrained and 0.7 if highlights are still cooking.

CategoryCFG Megapack/papers/combining the two predictions

Inputs (4)

NameTypeDefaultDescription
modelMODEL—
scaleFLOAT-1.0-1–100The guidance scale w for this rule. -1 uses the sampler's cfg value.
multiplierFLOAT1.00.1–100Raises the ceiling (large = plain CFG).
spaceCOMBOauto (the method's own)Where the rule is computed. Linear rules give the same image in any space; nonlinear ones do not. 'auto' uses the space the method was published in (noise for most, denoised for APG and the angle rule, velocity for flow models).

Outputs (1)

NameTypeDescription
MODELMODEL—