Image To Displacement Map
Make a displacement map from any image, no model download required
- image
- limit_mask
- displacement_map
- displacement_mask
- debug_image
Image To Displacement Map turns any image into a grayscale displacement map, with zero models, zero downloads, and no network. It's the pack's DIY answer to "I want the decal to follow the surface texture" - where a depth map handles big scene contour, a displacement map derived from the image itself captures the fine stuff: muscle definition, fabric folds, wrinkles. Feed it to Body Decal Apply's displacement_map input or to Body Decal Surface Warp, and the decal starts bending around the surface instead of floating over it.
How it works
The node grayscales your image and then processes it through one of four modes:
luminance- just the grayscale, blurred. The gentlest option; maps overall tone.highpass- subtracts a blurred version from the original, then recenters around neutral gray. This is the detail-extractor: fine texture stays, flat areas go neutral.soft_highpass- a gentler high-pass with a bigger blur radius. Smoother detail band.edges- a PIL edge filter, useful when what you want is to drive warp along boundaries.
Whatever the mode, the pipeline is the same after: an auto-stretch (using the 2nd and 98th percentiles so outliers don't dominate), recentering around neutral_gray, then contrast and strength applied on top. The ordering matters: neutral_gray is where the map does no shifting, and everything is recentered around it before strength pushes values away from it. invert flips the map, which flips the direction pixels get pushed.
Inputs and outputs
Required: image plus the mode enum. The controls: blur (0–30), contrast (0.1–10), strength (0–5), neutral_gray (0–1, default 0.5), invert, debug. The optional limit_mask is the neat one: it confines displacement to a region, and importantly, areas outside the mask become neutral gray, not black - because black in a displacement map means "shift hard one way," and a black surround would yank the decal's edges off. That detail is exactly why you'd rather use this node's map than a raw grayscale.
Outputs:
displacement_map(IMAGE) - the map itself; wire intodisplacement_maponBody Decal ApplyorBody Decal Surface Warp.displacement_mask(MASK) - how far each pixel deviates from neutral, i.e. where the map is actually doing something. Handy for masking the warped result.debug_image- the map rendered as an image for previewing.
Gotchas
A map of pure neutral gray does nothing, and a map of pure black or white does something terrible - you want variation, and highpass/soft_highpass are the modes that produce it. If the decal slides sideways instead of conforming, your neutral_gray doesn't match the map's midpoint; since the maps here are built around 0.5, keep the neutral inputs at 0.5 unless you know why you're changing them. And remember: this node makes maps, it doesn't apply them - nothing happens until a map is actually wired into a warp node, whose strength sliders default low. Install via Manager ("ComfyUI Body Decal") or git clone https://github.com/verias/comfyui-body-decal.git into custom_nodes and restart; numpy + Pillow only.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| mode | COMBO | 4 options: luminance, highpass, soft_highpass, edges | |
| blur | FLOAT | 2.00–30 | — |
| contrast | FLOAT | 1.50.1–10 | — |
| strength | FLOAT | 1.000–5 | — |
| neutral_gray | FLOAT | 0.500–1 | — |
| invert | BOOLEAN | false | — |
| debug | BOOLEAN | true | — |
| limit_maskopt | MASK | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| displacement_map | IMAGE | — |
| displacement_mask | MASK | — |
| debug_image | IMAGE | — |