Nodes/ComfyUI-BrainDead/BD Derive PBR Maps
ComfyUI Node

BD Derive PBR Maps

Heuristic PBR map derivation from a 2D image + depth map. Outputs roughness, metallic, AO, normal as separate maps + game-engine-ready packed ORM/ARM maps. These are HEURISTICS not measurements — for hero assets hand-tune downstream; for background characters, tuning the parameters is usually 'good enough'. Pair with an existing depth estimator (DepthAnythingV2, Lotus, MiDaS) upstream.

By BizaNator·Created 7 months ago·Updated 16 days ago· 14
BD Derive PBR Maps
  • image
  • depth
  • normal_map
  • silhouette_mask
  • aux_shading_alpha
  • aux_detail_texture
  • metallic_zone_mask
  • albedo
  • normal
  • roughness
  • metallic
  • ao
  • packed_orm
  • packed_arm
  • status
invert_shading_alphafalse
shading_to_roughness0.40
shading_to_ao0.50
detail_to_roughness0.50
depth_sharpen0.0
roughness_modecombined
roughness_default0.50
roughness_strength1.00
metallic_modeoff
metallic_default0.00
metallic_lum_threshold0.60
metallic_sat_threshold0.20
ao_strength0.70
ao_blur2.0
normal_strength2.0
albedo_treatmentedge_pad
albedo_edge_pad_pixels32
Category🧠BrainDead/Segmentation

Inputs (24)

NameTypeDefaultDescription
imageIMAGESource character/object image. Used for roughness (high-freq detail) and metallic (low-sat / high-lum heuristic) and as albedo passthrough.
depthIMAGEDepth map IMAGE from upstream estimator (DepthAnythingV2 / Lotus / MiDaS / Metric3D — all output IMAGE type). Closer surfaces darker by convention. Used for AO (cavity detection) and normal (when no explicit normal_map provided).
normal_mapoptIMAGEOptional explicit normal map IMAGE (e.g. from Metric3D-NormalMapPreprocessor or BAE-NormalMapPreprocessor). When provided, used directly. When NOT provided, normals are derived from the depth map's gradients.
silhouette_maskoptMASKOptional character/object silhouette MASK (white = subject, black = background). Multiplies all output maps so background pixels are zeroed in roughness/metallic, set to 1.0 in AO (no occlusion outside subject), and set to neutral (0.5, 0.5, 1.0) in normal map. Source: BiRefNetRMBG, BodySegment, or your existing skin/body chain.
aux_shading_alphaoptMASKOptional shading alpha map — e.g. the alpha output of your skin_details GLSL shader, where low alpha = highlights, high alpha = shaded zones. When provided: shaded areas get +roughness +AO -metallic; highlights get the opposite. This is FAR more accurate than the image-only heuristic for stylized art.
aux_detail_textureoptIMAGEOptional surface detail texture (lineart, manga lines, surface bumps). When provided, edge-detected lines boost roughness — useful for stylized character art where line detail represents real surface variation.
invert_shading_alphaoptBOOLEANfalseSet True if your shading alpha uses the opposite convention (low alpha = shaded, high alpha = highlight).
shading_to_roughnessoptFLOAT0.400–2How much shaded areas (high alpha) add to roughness. 0 = ignore shading for roughness; 0.4 = moderate boost; 1.0+ = strong (shaded → fully rough).
shading_to_aooptFLOAT0.500–2How much shading darkens AO (multiplicatively combined with depth-based AO). 0 = ignore; 0.5 = moderate; 1.0 = full (deeply shaded → near-black AO).
detail_to_roughnessoptFLOAT0.500–2How much detail texture lines boost roughness. Lines = surface detail = rougher. 0 = ignore; 0.5 = moderate; >1 = strong line emphasis.
depth_sharpenoptFLOAT0.00–3Unsharp mask the depth map before AO/normal derivation. Useful when your depth estimator (Lotus, Metric3D) gives smooth/chunky depth. 0 = no sharpen, 0.5-1.0 = moderate edge enhancement, 2-3 = aggressive.
roughness_modeoptCOMBOcombinedhigh_freq_detail: Laplacian magnitude → busy areas rougher (good for stylized art). luminance_inverted: bright = smooth, dark = rough (works for photo-lit subjects). combined: average of both. off: skip (output uses roughness_default).
roughness_defaultoptFLOAT0.500–1Used when roughness_mode=off, or as a baseline blended with the heuristic.
roughness_strengthoptFLOAT1.000–2Multiplier on the computed roughness map. <1 makes everything smoother, >1 boosts roughness contrast.
metallic_modeoptCOMBOoffoff: outputs metallic_default everywhere (typically 0). low_sat_high_lum: detect metallic candidates by bright + desaturated pixels. STRONGLY recommend wiring metallic_zone_mask too — heuristic alone gets false positives on bright skin/white cloth. With zone_mask=clothing+accessories, the heuristic becomes useful (bright desaturated pixels INSIDE clothing/accessories = metal candidates).
metallic_zone_maskoptMASKOptional MASK restricting where metallic CAN occur. Multiplies the metallic output, so only pixels inside the zone can be metal. Wire your clothing or accessories mask here (from a SAM3 'accessories,jewelry,metal' prompt, ClothesSegment, MaskResolver, etc.) — most game-character metal lives on jewelry/buckles/armor/details which align with the accessories category. Without this, metallic detection fires everywhere and produces false positives.
metallic_defaultoptFLOAT0.000–1Constant metallic value used everywhere when metallic_mode=off.
metallic_lum_thresholdoptFLOAT0.600–1Luminance above this counts toward metallic (when metallic_mode=low_sat_high_lum).
metallic_sat_thresholdoptFLOAT0.200–1Saturation below this counts toward metallic (when metallic_mode=low_sat_high_lum).
ao_strengthoptFLOAT0.700–2How much the depth gradients affect AO. 0 = pure white AO (no occlusion), 1 = full strength, >1 = exaggerated. AO is OUTPUT WHITE = no occlusion, DARK = occluded (Unreal/Unity convention).
ao_bluroptFLOAT2.00–20Gaussian blur radius for depth before computing gradients. Higher = softer AO.
normal_strengthoptFLOAT2.00.1–10Strength multiplier when deriving normals from depth. Higher = more pronounced normals. Only used when normal_map is NOT provided.
albedo_treatmentoptCOMBOedge_padHow to clean up the albedo output (was passing input through raw, which leaked transparent-area garbage colors as halo). edge_pad — extend foreground colors outward into background using Voronoi nearest-neighbor (game-engine standard 'alpha bleed'). Prevents UV edge halos. Requires silhouette_mask. silhouette_clip — multiply by silhouette_mask (background goes to black). Quick but causes black halos at UV edges in-engine. passthrough — original behavior (use input RGB as-is).
albedo_edge_pad_pixelsoptINT320–512When albedo_treatment=edge_pad: how far to extend foreground colors into transparent area. 0 = unlimited (pad everywhere — slow on huge images), 16-32 = typical for game textures, 64+ = aggressive.

Outputs (8)

NameTypeDescription
albedoIMAGE
normalIMAGE
roughnessMASK
metallicMASK
aoMASK
packed_ormIMAGE
packed_armIMAGE
statusSTRING