Nodes/ComfyUI-Paint3D-Nodes/3D_GenerateInpaintMask
ComfyUI Node

3D_GenerateInpaintMask

Mask + depth for the rotating inpaint pass

By N3rd00d·Created 2 years ago·Updated 2 years ago· 77
3D_GenerateInpaintMask
  • mesh_model
  • image
  • mask
  • depth
cam10
cam223

After the front/back pass, your mesh has paint on two faces and nothing on the other ~22. 3D_GenerateInpaintMask is the node that figures out what's still bare and hands you the mask, the current render, and the depth - the three things the rotating inpaint stage needs to fill in the rest of the model without disturbing what's already painted.

What it does

It renders the mesh from the two views you give it (cam1, cam2) and pulls three channels out of each render:

  • image - the current state of the model from those angles (the front/back paint you already projected, plus unpainted regions showing as the renderer's default color).
  • mask - the "uncolored mask": every pixel that the texture pass hasn't painted yet, thresholded to a clean 0/1. This is exactly what a masked inpainting stage needs - the model should regenerate those areas and leave the painted ones alone.
  • depth - the depth render from the same cameras, so geometry stays consistent while inpainting.

All three come back stitched into 2×1 grids, matching the size the KSampler latent expects. In the bundled workflow, image and mask go through an InpaintPreprocessor and then into ControlNetApplyAdvanced with the inpaint ControlNet (control_v11p_sd15_inpaint_fp16.safetensors), while depth drives a second depth-conditional pass. The paper does this with left/right 45° and up/down views; the author added 90°/135° rotations too, which is why this stage runs the inpaint KSampler four times.

Inputs that matter

  • mesh_model - the MESHMODEL carrying the current texture state (i.e. after 3D_Projection).
  • cam1 / cam2 - camera indices, 0–26, default 0 and 23. The defaults are the same front/back pair used in projection; change them when you're targeting specific side views.

Outputs

  • image (IMAGE) - current render of the two views, for the inpaint condition.
  • mask (MASK) - the single-channel unpainted mask. This is the one that tells the model where to regenerate.
  • depth (IMAGE) - depth map from the same cameras.

Installing

Same pack install as everything here - Manager search "ComfyUI-Paint3D-Nodes", or clone into custom_nodes and run:

pip install -r requirements.txt
pip install kaolin==0.15.0 -f https://nvidia-kaolin.s3.us-east-2.amazonaws.com/torch-2.1.0_cu121.html

You'll also want the SD1.5 inpaint ControlNet from comfyanonymous/ControlNet-v1-1_fp16_safetensors (control_v11p_sd15_inpaint_fp16.safetensors in models/controlnet) plus the depth one, and the UV Pos ControlNet for the final stage.

Gotchas

The mask is the thing to eyeball before you run the big inpaint loop. If it's showing regions that should already be painted (or missing regions that shouldn't be), the projection pass before it went wrong - re-check the camera indices in 3D_Projection. Also, inpaint_cfg and inpaint_denoise from 3D_TrainConfig govern this stage, not the txt2img pair; the defaults (CFG 3, denoise 1.0) are tuned for full regeneration of the mask area. As with everything in this pack, there's no real community FAQ to fall back on, so preview the three outputs and trust the masks.

CategoryPaint3D

Inputs (3)

NameTypeDefaultDescription
mesh_modelMESHMODEL
cam1INT00–26
cam2INT230–26

Outputs (3)

NameTypeDescription
imageIMAGE
maskMASK
depthIMAGE