Nodes/MKRShift_Nodes/Edge Wear Mask
ComfyUI Node

Edge Wear Mask

Procedural edge wear for PBR maps, the Subway-Surface way

By criskb·Created 7 months ago·Updated 5 months ago· 0
Edge Wear Mask
  • image
  • source_mask
  • mask
  • image
  • mask
  • wear_info
settings_json{"source_mode":"combined_edge_wear","normalize_mode":"auto_percentile","value_min":0.0,"value_max":1.0,"percentile_low":2.0,"percentile_high":98.0,"edge_radius":5.0,"detail_radius":2.0,"detail_strength":0.5,"gamma":1.0,"contrast":1.25,"blur_radius":0.0,"invert_values":false,"mask_feather":8.0,"invert_mask":false}

Texturing people with AI usually goes one of two ways: you generate a color map and call it a day, or you fight to derive every PBR channel by hand. x1EdgeWearMask is aimed at the second group - it's a one-node shortcut to that most game-art of all maps, the edge wear mask: the dirt-and-rust that accumulates along the corners and raised edges of a physical object where paint gets knocked off.

It's part of MKRShift Nodes by Cris K B, sitting under MKRShift Nodes/Surface/Maps alongside the pack's other material-map derivations like the emissive, roughness, and cavity maps. If you're building PBR textures in ComfyUI, this whole Surface branch is the reason to install the pack.

How it works

The trick to edge wear is that you don't need a fancy model - you need geometry cues, and those can come from the image itself. The node's default source_mode is combined_edge_wear: it derives an edge scalar by combining luminance edges and local contrast with a detail_radius high-frequency component, gated by a detail_strength amount. Raised edges and corners, where a real object would scrape, naturally light up in that combined signal. edge_radius (default 5.0) widens the wear band along those edges - small values give tight, crisp wear; large values spread the damage.

Then it's a normalization pipeline. normalize_mode defaults to auto_percentile (with percentile_low/percentile_high, default 2/98) which stretches the values so the wear range actually uses the full 0-1 scale instead of hugging the middle. value_min / value_max are the manual fallback if you'd rather set the range yourself. gamma and contrast shape the falloff of the wear - how hard-edged the transition from pristine to scraped is - and blur_radius smooths the whole thing if it comes out noisy. invert_values flips it to a "clean areas" mask if you want the untouched surface instead.

The inputs that matter

  • source_mode - combined_edge_wear is the default; it's the "just give me wear" option.
  • edge_radius - the width of the wear band (default 5.0).
  • detail_strength - how much fine surface detail feeds the mask (default 0.5).
  • gamma / contrast - the shape of the wear falloff; this is where you dial "subtle" vs "battle-worn."
  • normalize_mode - leave on auto_percentile unless you know why you're changing it.

There's an optional source_mask if you want to derive wear from a specific area, plus the usual mask / mask_feather / invert_mask for localizing the output. The node outputs image, mask, and a wear_info string. Wire the mask into a mix/alpha where you composite a dirt texture onto your albedo, or use it to mask rust in a roughness map.

Installing it

cd ComfyUI/custom_nodes
git clone https://github.com/criskb/MKRShift_Nodes

Restart ComfyUI, or install via ComfyUI Manager (search MKRShift_Nodes). No requirements.txt, no model files - this runs purely on numpy/PIL/torch.

The honest caveat

This derives wear from the image, not from real 3D geometry. On a generated albedo of a cube, the wear will follow the drawn edges and contrast - which is often exactly right, but on a flat diffuse texture it has nothing to grip. Feed it an image with strong lighting or a cavity/curvature pass if you have one, and treat auto_percentile normalization as your friend: it's what keeps the result usable without manual remapping. It won't replace Substance Painter's curvature baker, but it's dramatically faster than hand-painting a wear mask, and for stylized or game-ready work it gets you 90% of the way.

CategoryMKRShift Nodes/Surface/Maps

Inputs (4)

NameTypeDefaultDescription
imageIMAGE
settings_jsonSTRING{"source_mode":"combined_edge_wear","normalize_mode":"auto_percentile","value_min":0.0,"value_max":1.0,"percentile_low":2.0,"percentile_high":98.0,"edge_radius":5.0,"detail_radius":2.0,"detail_strength":0.5,"gamma":1.0,"contrast":1.25,"blur_radius":0.0,"invert_values":false,"mask_feather":8.0,"invert_mask":false}
source_maskoptMASK
maskoptMASK

Outputs (3)

NameTypeDescription
imageIMAGE
maskMASK
wear_infoSTRING