Gradient Mask Generator
Procedural Masks Without a Single Painted Pixel
- mask
Sometimes the mask you need isn't derived from anything - it's just made. Gradient Mask Generator creates gradient masks from scratch at any size: linear, radial, angle, diamond, or square, with a center you can position and optional noise on top. It's the "generate a clean procedural selection" node, and for material work it's surprisingly central: soft radial masks for localized weathering, linear gradients to fade detail across a tile, angle gradients for directional effects.
It's in the Masks category of amtarr/ComfyUI-TextureAlchemy, the PBR/texture toolkit. No input image required - this is one of the pack's generator nodes, which makes it a great thing to reach for when you're building a material procedurally rather than processing a photo.
How it works
It rasterizes a mathematical gradient onto a tensor of your chosen size. The gradient_type determines the shape:
- linear - a straight ramp;
anglerotates it. - radial - a circle out from
center_x/center_y, soft edge, great for vignette-style masks. - angle - a sweep around the center (think a compass rose gradient).
- diamond - like a rotated square falloff; useful for stylized panel fading.
- square - a hard-edged falloff from a rectangle.
noise_amount and noise_scale overlay a value noise pattern on the ramp - a masked-noise trick that makes procedural masks read as organic dirt or wear instead of perfect geometry. seed makes the noise reproducible. invert flips the ramp.
The inputs that matter
width/height(64–8192, stepped by 64) - output size. Pick it to match the texture you'll composite onto.gradient_type- the five shapes above.angle(0–360) - direction for linear/angle types.center_x/center_y(0–1) - where the gradient originates, as fractions of the image.noise_amount(0–1),noise_scale(1–100) - organic variation.invert,seed.
Output is a mask IMAGE (white-to-black gradient).
Where it slots in
The classic move is feed it to a blend node as the mask input - a radial gradient behind a texture overlay gives you a soft-focus fade, a linear gradient controls where a weathering pass applies. It also pairs with the pack's Color Ramp-style nodes for stylized materials: gradient → color ramp → hand-painted-looking albedo. Since it's fully procedural, it's also your reproducibility friend: same seed, same size, same mask, every time.
Installing it
Same pack, same install:
cd ComfyUI/custom_nodes
git clone https://github.com/amtarr/ComfyUI-TextureAlchemy
restart, and it's under Texture Alchemist → Masks. ComfyUI Manager: search "Texture Alchemy". No extra dependencies.
Gotchas
Two things. First, the output is an IMAGE, not a MASK type - same story as the pack's Color Selection Mask, so check what your downstream node wants. Second, noise_scale interacts with resolution: a scale that looks right at 512 becomes big chunky blobs at 4K, so rescale or re-pick it when you change size. And the "square" type isn't a gradient in the way you'd expect - it's a rectangular falloff, so if you wanted a linear ramp, you probably wanted "linear" with a 0° angle.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| width | INT | 51264–8192 | — |
| height | INT | 51264–8192 | — |
| gradient_type | COMBO | 5 options: linear, radial, angle, diamond, square | |
| angle | FLOAT | 00–360 | Gradient angle (degrees) |
| center_x | FLOAT | 0.500–1 | Center X position (0-1) |
| center_y | FLOAT | 0.500–1 | Center Y position (0-1) |
| noise_amount | FLOAT | 0.000–1 | Add noise variation |
| noise_scale | FLOAT | 201–100 | — |
| invert | BOOLEAN | false | — |
| seed | INT | 00–18446744073709550000 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| mask | IMAGE | — |