Normal → Curvature (MEC)
Turn a normal pass into an edge-wear mask in one node
- normal
- curvature
If you've ever rendered a tangent-space normal pass and thought "I wish I had a mask of where the edges are," this is that node. Normal → Curvature (MEC) takes an IMAGE normal pass and returns a MASK where curvature is high - crevices, bevel edges, wear lines - with flat areas sitting at middle gray. It's a staple in the VFX/comp toolbox this pack ships, and it's the kind of thing that used to require a tangle of math nodes or a trip into Nuke.
The math under the hood
How it works is refreshingly grounded in geometry instead of a neural net. The input is a tangent-space normal pass, which encodes surface direction as RGB: x is red, y is green, z is blue. The node maps those [0,1] values back to [-1,1], then computes the divergence of the normal field - effectively ∂Nx/∂x + ∂Ny/∂y via central differences. Where normals change rapidly (an edge), divergence spikes; where they're flat, it's near zero. That number is scaled, normalized per frame with 0.5 as "flat," and clamped to [0,1] as a mask. No model download, no inference, pure tensor math - it runs instantly even on a batch of 4K frames.
The one knob that matters
The one knob that matters is scale, default 1.0 (range 0.1–32). It multiplies the curvature before normalization, so crank it up to exaggerate faint bevels and cavity detail, keep it low when you only want strong edges. There's genuinely nothing else to set, which is the whole appeal.
Where a curvature mask earns its keep
What do you do with a curvature mask in ComfyUI? The classic uses: edge wear and weathering - multiply it with a grunge or noise texture and composite it over a surface for procedural wear; cavity AO - a curvature mask is the cheap stand-in for ambient occlusion in a lot of stylized comps; and detail isolation - use it as a control for selective sharpening or a KSampler mask so you only touch the edges. If you've got a clean-plate/render-pass pipeline running, this slots in right before the compositing stack.
Wiring and install
It wires anywhere a MASK goes. Feed the curvature output into a Mask Composite Advanced (MEC), a blend node, or straight into a conditioning mask for regional generation. The normal input expects a proper tangent-space normal pass - world-space normals will give you junk, since the math assumes z points along the surface normal. If your renderer outputs object-space or world-space normals, convert to tangent space first or you'll get nonsense out.
Install is the shared pack: clone Code2Collapse/ComfyUI-CustomNodePacks into ComfyUI/custom_nodes (or "CustomNodePacks" in ComfyUI Manager), restart, find it under MaskEditControl/Geometry. Needs opencv-python and scipy from the pack's requirements - both usually present, but check if this is your first MEC node. It's one of the quiet utility wins in a big pack: a single-purpose math node that does exactly one thing, does it fast, and doesn't try to upsell you into a model download.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| normal | IMAGE | — | |
| scaleopt | FLOAT | 1.00.1–32 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| curvature | MASK | — |