ZML_对比度脚本
Mid-sampling contrast, brightness, and vignette — inside the sampler
- 上一个脚本
- 脚本
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.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| 触发时机 | FLOAT | 0.50–1 | — |
| 对比度 | FLOAT | 1.000–3 | 1.0为原样,大于1增加对比度 |
| 亮度 | FLOAT | 0.0-10–10 | 0.0为原样,正数变亮,负数变暗(大幅度调节Channel 0) |
| 暗角强度 | FLOAT | 0.00–10 | 值越大,四周越暗 (建议 0.5-2.0) |
| 上一个脚本opt | ZML_SCRIPT | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| 脚本 | ZML_SCRIPT | — |