Nodes/ComfyUI-BrainDead/BD Depth To Shadow Map
ComfyUI Node

BD Depth To Shadow Map

Derive a procedural greyscale shadow map from a depth image. Combines: • N·L lighting from depth-derived surface normal (default top-down) • Cavity ambient occlusion from depth Laplacian (eye sockets, mouth crease) • Ambient floor Output is a greyscale image suitable for u_image3.R in the skin shader, or any downstream node that uses a luma-based shadow multiplier. Geometry-aware: automatically carves shadow into recesses (eye sockets, cheek hollows) and lights upward-facing surfaces (forehead, brow ridge). Designed for the zombie variant of the multi-tone skin pipeline.

By BizaNator·Created 7 months ago·Updated 16 days ago· 14
BD Depth To Shadow Map
  • depth
  • mask
  • shadow_map
  • normal_map
  • cavity_map
  • measured_max_curvature
light_x0.00
light_y-1.00
light_strength0.70
ao_strength0.60
ao_radius8
ambient0.35
depth_blur2.0
invert_depthfalse
Category🧠BrainDead/Segmentation

Inputs (10)

NameTypeDefaultDescription
depthIMAGEDepth map image. Brighter = closer to camera. Typically from Lotus2 or a depth estimator. If RGB, the R channel is used.
light_xFLOAT0.00-1–1Light direction X (image-space). -1=left, +1=right, 0=centered.
light_yFLOAT-1.00-1–1Light direction Y (image-space). -1=TOP (default, top-down lighting), +1=bottom, 0=horizontal.
light_strengthFLOAT0.700–2How much N·L contributes to final shadow. 0=disable top-light, 1=full Lambertian, >1=exaggerated.
ao_strengthFLOAT0.600–2How much cavity AO contributes. 0=disable, 1=normal, >1=exaggerated darkness in recesses (more zombie). This is what creates the sunken-eye / hollow-cheek look.
ao_radiusINT81–64Pixel radius for cavity detection (Laplacian sigma). 8-16 catches eye sockets / cheek hollows. Smaller = fine creases only. Larger = broad hollows.
ambientFLOAT0.350–1Minimum output value (ambient floor). Prevents pure-black voids. 0.35 = output never goes below 35% grey. Higher = brighter overall.
depth_blurFLOAT2.00–16Pre-blur applied to depth before normal computation. Higher = smoother lighting (less noisy). 0 = raw depth. Helps if depth has stair-step quantization or noise.
invert_depthBOOLEANfalseON: treat darker pixels as closer (Lotus2 convention is the opposite). Toggle if shadows appear inverted (sockets lit, peaks dark).
maskoptMASKOptional mask. Pixels outside the mask get the ambient floor value (not the computed shadow). Use a skin mask to limit AO to face.

Outputs (4)

NameTypeDescription
shadow_mapIMAGEGreyscale shadow map (R=G=B). 1.0=fully lit, 0.0=fully shadowed (clamped by ambient floor). Wire to u_image3.R input (or use as a shadow_mult multiplier in any pipeline).
normal_mapIMAGEDerived surface normal visualized as RGB. R=nx, G=ny, B=nz, encoded [-1,+1] → [0,1] (standard tangent-space normal map). Useful for debugging or downstream lighting nodes.
cavity_mapIMAGECavity AO term in isolation (R=G=B). 1.0=open surface, 0.0=deepest cavity. Useful for visualizing what AO is detecting.
measured_max_curvatureFLOATPeak Laplacian magnitude in the depth — useful for tuning ao_strength across characters with different depth scales.