Nodes/ComfyUI-TextureAlchemy/Scratches Generator
ComfyUI Node

Scratches Generator

Procedural wear without touching a sampler

By amtarr·Created 9 months ago·Updated 4 months ago· 58
Scratches Generator
    • scratches
    • height
    width512
    height512
    density0.30
    length_min50
    length_max200
    width_scratch1.0
    angle_variation180
    intensity0.80
    seed0

    Scratches are the fastest way to make a material stop looking like plastic, but generating them with a diffusion model is overkill and a lot of VRAM. Scratches Generator just draws them. It's a pure procedural node: give it a canvas size, a density, and a seed, and it paints a field of scratch lines on a black background. No model, no weights, no sampling - it's the kind of utility you reach for when you want a wear plate to multiply into a roughness or metallic map.

    How it works

    The generator picks a random start point for each scratch, a random length between length_min and length_max, and a random angle. angle_variation controls the angular spread - 0 makes every scratch vertical, 180 means all directions. Each line is rasterized with a soft-edged falloff at intensity brightness and a pixel width set by width_scratch. The number of scratches is width × height × density / 10000, so it scales with pixel area - quadruple the pixels and you get four times the scratches.

    It outputs two things:

    • scratches - white lines on black, ready to multiply into roughness or use as a wear mask.
    • height - the same scratches as a height field (1 - scratches * 0.3), so grooves read as darker indentations. Wire it into a height input or a height-to-normal converter if you want actual geometry.

    The seed input makes the pattern reproducible, which matters when you're iterating on a material set and want the same scratches on the albedo and the roughness map.

    What to set first

    Density is the one that shapes the result most - 0.3 is a light scuff, 0.8 is a heavily beat-up surface. intensity is brightness, not opacity of the effect; 0.8 reads as proper bright scratches, and dropping it to ~0.3 gives faint micro-scratches that sit nicely under a roughness detail pass. Keep width_scratch near 1 for believable hairline marks.

    Installing and running it

    It's part of the amtarr/ComfyUI-TextureAlchemy pack. Install via ComfyUI Manager (search "Texture Alchemy") or:

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

    Then restart and find it under right-click → Add Node → Texture Alchemist → Procedural. The pack has no extra dependencies and no model files - everything runs on the PyTorch/PIL/NumPy that ComfyUI ships.

    The honest gotchas

    This one is CPU-bound in a way that hurts. Each line is drawn in a Python loop with a hand-rolled line rasterizer, and the scratch count scales with pixel area. At 2048×2048 with high density it turns into a wait, and 8192 (the max) with density near 1.0 is genuinely slow. Build and preview at 512 or 1024, then bump up for the final pass. Also worth knowing: the pack prints a banner to the console on every run - normal behavior, not an error. If your scratches come out looking like a scribble pad, lower density and raise length_min; dense short scratches read as noise, sparse long ones read as wear.

    CategoryTexture Alchemist/Procedural

    Inputs (9)

    NameTypeDefaultDescription
    widthINT51264–8192
    heightINT51264–8192
    densityFLOAT0.300–1Number of scratches
    length_minFLOAT505–500
    length_maxFLOAT2005–1000
    width_scratchFLOAT1.00.5–10Scratch width in pixels
    angle_variationFLOAT1800–180Angular spread (0=vertical, 180=all directions)
    intensityFLOAT0.800–1Scratch brightness
    seedINT00–18446744073709550000

    Outputs (2)

    NameTypeDescription
    scratchesIMAGE
    heightIMAGE