Nodes/ComfyUI-TextureAlchemy/Gradient Map (Mask)
ComfyUI Node

Gradient Map (Mask)

Turn a height map into a selection mask with two sliders

By amtarr·Created 9 months ago·Updated 4 months ago· 58
Gradient Map (Mask)
  • image
  • mask
input_range_min0.00
input_range_max1.00
invertfalse
smoothness0.00

Here's a material-art problem with a clean answer: you have a height map and you want to affect only the raised plateaus - or only the deep grooves - and leave the rest alone. Doing that by hand is a nightmare of thresholding. This node gives you two sliders, input_range_min and input_range_max, and turns any grayscale-ish map into a soft selection mask. Everything below the minimum goes black, everything above the maximum goes white, and everything between ramps smoothly. That's the whole trick, and it's one of the most frequently useful nodes in the pack.

Mechanically it's a remap. The input is converted to grayscale, then each pixel is mapped from your range onto 0–1: (value - min) / (max - min), clamped. Below min → 0, above max → 1, in between → a gradient. The smoothness control (0–0.5) then applies a smoothstep - that S-shaped curve - so the transition softens from a hard band into a gentle falloff. Higher values run more smoothing passes for an even softer edge. invert flips the whole thing when you want the valleys instead of the peaks.

The three controls you'll actually touch:

  • input_range_min / input_range_max - the value window you're selecting (both 0–1, since maps live in 0–1)
  • smoothness - edge softness; 0 for hard selections, ~0.1–0.3 for feathered ones
  • invert - flip the selection

Output is a single mask IMAGE (white = selected), ready to plug into a blend mask, the Detail Map Blender, a compositing mix, or anywhere this pack expects a mask.

This is the node the pack's own docs point to for "select height ranges," and it composes beautifully with the rest of the toolkit. A classic chain: height map → Gradient Map to isolate the plateaus → Color Ramp to paint them gold. Or AO → Gradient Map for the deepest crevices → use the mask to drive grime placement, which pairs naturally with the Dirt/Grime Mask Generator. You can also chain it into Edge Detection or Curvature output for value-based selections of wear zones.

The one thing to keep in mind: it works on value ranges, not on spatial regions. A mask from this node selects "all pixels in this brightness band" - which is usually exactly what material work needs, but if you want a specific region of the image, you want the pack's crop-to-mask nodes instead. Different tools, different jobs.

Install: Manager → search "Texture Alchemy", or:

cd ComfyUI/custom_nodes
git clone https://github.com/amtarr/ComfyUI-TextureAlchemy

Restart, then Texture Alchemist/Effects → Gradient Map (Mask). No dependencies, no model files. Shared gotchas: the README's copy step uses the pre-rebrand folder name, and if Manager blocks a Git-URL install, that's the security level - clone by hand.

CategoryTexture Alchemist/Effects

Inputs (5)

NameTypeDefaultDescription
imageIMAGE
input_range_minFLOAT0.000–1Values below this become black
input_range_maxFLOAT1.000–1Values above this become white
invertBOOLEANfalseInvert the mask
smoothnessFLOAT0.000–0.5Edge smoothness (0=hard, >0=soft)

Outputs (1)

NameTypeDescription
maskIMAGE