Auto Contrast/Levels
The 'fix it automatically' contrast node
- image
- result
Flat, muddy textures are the default state of a lot of extracted maps. You run an extractor, you get a roughness or height map that sits in a narrow band of gray instead of using the full 0–1 range, and every downstream node is worse for it. Auto Contrast/Levels is the "make this map actually use its full range" node - it stretches the histogram so the darkest pixel is black and the brightest is white, and it does it per your tolerance for clipping.
It's basically the Auto Levels button from every photo editor, minus the UI. You drop an image in, get a properly-stretched image out, and the only real decision is how aggressive to be with the clip.
How it works
It sorts the pixel values, finds the percentile points at each end of the histogram, and remaps the range between them to 0–1. The clip_percent (default 1.0) is the interesting bit: it trims that percentage of the histogram's extremes before stretching. Clipping exists because a single stray black pixel or blown highlight will otherwise drag the whole map's range and crush your midtones - clip a little and the stretch becomes robust to outliers. The mode controls whether it stretches based on luminosity (one remap for all channels, preserves color relationships) or per-channel (each of R, G, B remapped independently, which can shift color but maximizes each channel's range).
The inputs
image- anything, but it shines on grayscale maps: height, roughness, AO, masks.clip_percent- 0–10. Start at the default of 1. If your map still looks flat, nudge it to 2–3; if you see banding or blown regions, back it down.mode-luminosityorper_channel.
Output is a single result IMAGE.
Where it fits and what to watch
Use it after an extractor or generator produces a low-contrast map and before you feed that map into a channel packer, a saver, or a PBR pipeline. The classic failure mode is over-clipping: crank clip_percent up and you clip real data at both ends, which turns into posterized roughness maps. Another thing to remember - per-channel mode on a color albedo can shift the color balance, so for color work use luminosity, and reserve per-channel for grayscale maps where you genuinely want every channel maxed.
Installation
Part of amtarr/ComfyUI-TextureAlchemy, under Add Node → Texture Alchemist → Color. Install via ComfyUI Manager (search "TextureAlchemy") or:
cd ComfyUI/custom_nodes
git clone https://github.com/amtarr/ComfyUI-TextureAlchemy
Restart ComfyUI. No dependencies, no models - pure histogram math on the GPU.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| clip_percent | FLOAT | 1.00–10 | Percent of histogram to clip at extremes |
| mode | COMBO | 2 options: luminosity, per_channel |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| result | IMAGE | — |