Nodes/ComfyUI-ZML-Image/ZML_对比度脚本
ComfyUI Node

ZML_对比度脚本

Mid-sampling contrast, brightness, and vignette — inside the sampler

By zml-w·Created about a year ago·Updated 2 months ago· 218
ZML_对比度脚本
  • 上一个脚本
  • 脚本
触发时机0.5
对比度1.00
亮度0.0
暗角强度0.0

Normally you adjust contrast and brightness after the image is done, as a post-process. This node lets you do it during sampling - at a chosen point in the diffusion process, it tweaks the latent directly, then keeps sampling from there. It's part of the ZML pack's "script" system: you build a chain of adjustments, and the ZML_K sampler applies them at the exact progress step you set.

How it works

Script nodes output a ZML_SCRIPT list, not an image. Each one appends a small dict - here {"type": "contrast", "timing": ..., "contrast": ..., "brightness": ..., "vignette": ...} - to the script, sorted by timing. When the ZML_K sampler runs, it converts your timing (0.0–1.0) into a concrete step number and fires the operation at that step, editing the latent in place before sampling continues.

What does it actually do to the latent? The name overpromises slightly. In the source, brightness is applied as a straight offset to the latent channel, and the vignette darkens toward the edges of the latent. It's a crude approximation of what Photoshop would do - don't expect a film-grade grade - but it's exactly the kind of trick that gives you a "the image just pops more" result without a separate upscale-then-grade pass.

The inputs that matter

  • 触发时机 (timing) - progress at which the adjustment fires, 0.0 = start, 1.0 = end. Default 0.5, so roughly halfway through.
  • 对比度 (contrast) - 1.0 is unchanged; above 1 increases contrast. The tooltip from the author says it plainly.
  • 亮度 (brightness) - 0.0 unchanged, positive brighter, negative darker. The tooltip notes large swings adjust "Channel 0" - i.e. it's a blunt latent-space lever, not per-pixel exposure.
  • 暗角强度 (vignette) - bigger = darker corners; the author suggests 0.5–2.0.
  • 上一个脚本 (previous script) - chain more script nodes here. Wire a Dynamic CFG script into this socket and both fire in the same run.

Output is 脚本 (ZML_SCRIPT), which goes into the script input on a ZML sampler.

Installing

Same as the rest of the pack - ComfyUI Manager, or:

cd ComfyUI/custom_nodes
git clone https://github.com/zml-w/ComfyUI-ZML-Image

then restart ComfyUI. Grab the English translation patch from https://github.com/zml-w/ZZZ_ZML_English_Patch if the Chinese labels bother you. Nothing extra downloads for this node.

The catch

The script only takes effect with a ZML sampler that understands ZML_SCRIPT - plugging this into a stock KSampler does nothing. And because it edits the latent, the same contrast value behaves differently across models, samplers, and CFG settings. The defaults are conservative for a reason: go wild with contrast 3.0 and you can shove the latent into broken territory. Start at 1.1–1.2 and nudge. It's a "small seasoning, one light adjustment" tool, and treating it like a full grading pass is how people end up with fried images.

Categoryimage/ZML_图像/采样器相关

Inputs (5)

NameTypeDefaultDescription
触发时机FLOAT0.50–1
对比度FLOAT1.000–31.0为原样,大于1增加对比度
亮度FLOAT0.0-10–100.0为原样,正数变亮,负数变暗(大幅度调节Channel 0)
暗角强度FLOAT0.00–10值越大,四周越暗 (建议 0.5-2.0)
上一个脚本optZML_SCRIPT

Outputs (1)

NameTypeDescription
脚本ZML_SCRIPT