Nodes/BrainDead Nodes/BD Face Texture Bake
ComfyUI Node

BD Face Texture Bake

Nvdiffrast UV bake that turns head photos into a face texture

By BizaNator·Created 8 months ago·Updated 3 days ago· 15
BD Face Texture Bake
  • images
  • face_fit
  • uv_textures
  • confidences
  • uv_layout_mask
  • status
view_index-1
texture_size2048
min_confidence0.00

This is where the FaceWrap pipeline turns from "we have landmarks and a head mesh" into "we have an actual face texture." BD Face Texture Bake rasterizes your source head photos into the canonical UV layout using nvdiffrast - per UV texel it interpolates the mesh's per-view vertex positions into source-image coordinates and bilinearly samples the photo. The output is a batch of per-view baked textures plus per-view confidence masks that feed straight into the blend step.

How it works

For each view, for each output UV texel: rasterize the canonical UV layout → interpolate the 3 corner verts_2d → bilinear-sample the source image at that coordinate. The confidence mask is the front-facingness of the underlying triangle, clamped to [0,1] - so a frontal view gets high confidence across the face, and a view barely touching a texel contributes weakly. That confidence is the currency the downstream BD_UVConfidenceBlend spends when it merges views.

Inputs:

  • images - source photo batch, same order/count as the LANDMARKS_BATCH the FACE_FIT was built from.
  • face_fit - from BD Face Fit (canonical mesh + per-view 2D vertex positions).
  • view_index (-1) - default bakes all detected views. Set ≥ 0 to bake a single view for debugging; output stays a 1-length batch so wiring doesn't change.
  • texture_size (2048) - UV texture resolution; 8192 max if you're doing hero-quality.
  • min_confidence (0) - texels with face-cosine below this get zeroed in the mask.

Outputs: uv_textures (batch), confidences (mask batch), uv_layout_mask (a view-independent mask marking every texel that maps to a mesh triangle - wire it into BD_UVConfidenceBlend.target_mask so gaps no view filled get inpainted), and status. Undetected views (rear, failed detection) are skipped entirely - no landmarks, nothing to contribute.

Installing

ComfyUI Manager → search "BrainDead" → install, or:

cd ComfyUI/custom_nodes
git clone https://github.com/BizaNator/ComfyUI-BrainDead
cd ComfyUI-BrainDead
pip install -r requirements.txt

Restart. Requires nvdiffrast - a CUDA rasterizer. If you see an import error at load, pip install nvdiffrast in your environment (and yes, you need CUDA; the CPU fallback isn't a thing here).

Where people get burned

The pipeline is only as good as its alignment: if the FACE_FIT was built from different photos than the ones you're baking, everything smears - keep the image batch and landmarks in lockstep. Second: don't skip the confidence outputs. The un-blended baked texture from one view will have seams and ghosting; the confidence masks exist to make the blend work, so wire them into UVConfidenceBlend rather than eyeballing a single view. And view_index ≥ 0 is a debugging tool, not a production setting - baking everything is the intended path.

Category🧠BrainDead/FaceWrap

Inputs (5)

NameTypeDefaultDescription
imagesIMAGESource photo batch — same order/count as the LANDMARKS_BATCH the FACE_FIT was built from.
face_fitBD_FACE_FITFACE_FIT from BD_FaceFit. Provides canonical mesh + per-view 2D vertex positions.
view_indexINT-1-1–63-1 = bake ALL detected views (default). >= 0 = bake only that view index.
texture_sizeINT2048256–8192Output UV texture resolution.
min_confidenceoptFLOAT0.000–1Texels with face-cosine below this are zeroed in the mask.

Outputs (4)

NameTypeDescription
uv_texturesIMAGE
confidencesMASK
uv_layout_maskMASK
statusSTRING