Nodes/ComfyUI-TextureAlchemy/Dirt/Grime Mask Generator
ComfyUI Node

Dirt/Grime Mask Generator

Procedural grime that knows where the crevices are

By amtarr·Created 9 months ago·Updated 4 months ago· 58
Dirt/Grime Mask Generator
  • ao_map
  • height_map
  • mask
width512
height512
density0.50
scale20
crevice_strength0.70
contrast1.0
seed0

A flat noise texture can fake dirt, but real grime doesn't land evenly - it pools in crevices, gathers in shadows, skips the high spots that get wiped clean. This node generates a procedural dirt mask that actually respects that behavior, and it does it without any input images at all. Give it a resolution and a seed, and you get a grime mask back. Feed it your AO and height maps, and the grime suddenly knows where the grooves are.

The generator starts with four octaves of bilinear-upsampled random noise, stacked with decreasing amplitude - the classic multi-scale fractal noise trick. Higher octaves add fine speckle, lower octaves shape the broad patches, so you get natural, non-repeating dirt rather than a flat salt-and-pepper texture. Then it applies a contrast curve and a density threshold: density controls overall coverage (how much of the surface ends up dirty), scale sets the size of the dirt patches, and contrast pushes the pattern toward binary or keeps it soft. seed makes the whole thing reproducible, which matters if you're iterating on a look and want to regenerate the same pattern after a tweak.

The interesting inputs are the optional ones:

  • ao_map - dirt accumulates in crevices, and AO is literally a map of how enclosed each region is. The generator multiplies its noise by the AO, so dark crevices collect more grime. This is the difference between "random speckles" and "dirt that looks like it settled somewhere."
  • height_map - used similarly to bias the pattern by elevation, so valleys stay grimy and ridges stay clean.

Wire both in and the mask stops looking procedural at all; it starts looking like a real weathering pass.

Output is a single mask IMAGE. White = grime. That mask is meant to drive other nodes: multiply it against a darkening color to tint the albedo, use it to mask the Detail Map Blender so grime adds texture only in dirty regions, or blend it into a roughness map so grimy areas get rougher (or slicker, if you want wet grime). The whole pack is built around masks being wiring glue, and this is one of the more satisfying ones.

The workflow that makes it sing: extract a PBR material, generate dirt here using the material's own AO and height, then use the mask to weather the albedo and roughness. It's the cheap, GPU-instant alternative to training a weathering model, and for most stylized or game-ready materials it's plenty.

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

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

Restart, then Texture Alchemist/Masks → Dirt/Grime Mask Generator. No dependencies, no model downloads - it's torch noise math, and it generates on GPU. Remember: the README's manual-copy instructions reference the old pack folder name, and if Manager blocks a Git-URL install, that's the security level - clone manually.

CategoryTexture Alchemist/Masks

Inputs (9)

NameTypeDefaultDescription
widthINT51264–8192
heightINT51264–8192
densityFLOAT0.500–1Overall dirt coverage
scaleFLOAT201–100Size of dirt patches
crevice_strengthFLOAT0.700–1Dirt accumulation in crevices
contrastFLOAT1.00.1–3Dirt pattern contrast
seedINT00–18446744073709550000
ao_mapoptIMAGE
height_mapoptIMAGE

Outputs (1)

NameTypeDescription
maskIMAGE