Nodes/ComfyUI-TextureAlchemy/Gradient Mask Generator
ComfyUI Node

Gradient Mask Generator

Procedural Masks Without a Single Painted Pixel

By amtarr·Created 9 months ago·Updated 4 months ago· 58
Gradient Mask Generator
    • mask
    width512
    height512
    gradient_type
    angle0
    center_x0.50
    center_y0.50
    noise_amount0.00
    noise_scale20
    invertfalse
    seed0

    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; angle rotates 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.

    CategoryTexture Alchemist/Masks

    Inputs (10)

    NameTypeDefaultDescription
    widthINT51264–8192
    heightINT51264–8192
    gradient_typeCOMBO5 options: linear, radial, angle, diamond, square
    angleFLOAT00–360Gradient angle (degrees)
    center_xFLOAT0.500–1Center X position (0-1)
    center_yFLOAT0.500–1Center Y position (0-1)
    noise_amountFLOAT0.000–1Add noise variation
    noise_scaleFLOAT201–100
    invertBOOLEANfalse
    seedINT00–18446744073709550000

    Outputs (1)

    NameTypeDescription
    maskIMAGE