Nodes/ComfyUI-Paint3D-Nodes/3D_GenerateInpaintUVMapMask
ComfyUI Node

3D_GenerateInpaintUVMapMask

UV map + mask for the final cleanup pass

By N3rd00d·Created 2 years ago·Updated 2 years ago· 77
3D_GenerateInpaintUVMapMask
  • mesh_model
  • albedo
  • mask
  • uv_map

By the end of the rotating inpaint passes your model is fully painted - and also full of seams, projection boundaries, and little square patches of default color where the views didn't quite line up. 3D_GenerateInpaintUVMapMask is the cleanup stage: it produces the two things needed to run one final inpaint in UV space instead of in camera space, which is the only sane way to fix boundary artifacts across a whole texture at once.

What it does

Two renders happen here. First it renders the mesh's UV position map - a texture-space image where each texel encodes the 3D position it corresponds to. That's what the UV Pos ControlNet (Paint3d_UVPos_Control.bin, from GeorgeQi/Paint3d_UVPos_Control) consumes: a condition that tells the SD1.5 model exactly which texel maps to which surface point, so the final inpaint stays glued to the geometry.

Second, it builds the mask for that inpaint pass. It takes your current albedo texture and finds the background pixels by exact color key - the renderer's untextured default is a magenta [204, 25, 204], so anything still that color is flagged. The mask is then dilated with a 15px kernel to catch the ragged edges around painted regions, which is what makes the inpaint blend across projection seams instead of leaving a hard outline.

In the workflow, the uv_map feeds the UV Pos ControlNet, and the mask goes into the final inpaint KSampler - this is the "light-less texture" pass that removes residual shading and squares up the boundaries, per the README.

Inputs that matter

  • mesh_model - the MESHMODEL in its fully painted state.
  • albedo - the current IMAGE texture map (the albedo output of 3D_Projection). The mask is computed from this, so don't skip the earlier stage and feed it something random.

Outputs

  • mask (MASK) - the dilated background mask marking what still needs UV-space inpainting.
  • uv_map (IMAGE) - the UV position map for the UV Pos ControlNet.

Installing

Same as the rest of the pack - Manager search "ComfyUI-Paint3D-Nodes" or clone into custom_nodes, then:

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

That second line (kaolin) is the install that breaks for people - it needs torch 2.1.0 + cu121 to match the wheel. The UV Pos ControlNet download is the pack-specific piece: grab Paint3d_UVPos_Control.bin from GeorgeQi/Paint3d_UVPos_Control and drop it in ComfyUI/models/controlnet under a sd15/ subfolder to match the workflow's paths.

Gotchas

Two things trip people up. First, the mask is color-keyed to the default magenta - if your model's existing texture legitimately contains that exact [204, 25, 204] color, it'll get masked as unpainted background. It's rare, but it's the kind of silent artifact that's maddening to hunt down. Second, the UV Pos ControlNet is SD1.5-only, so this stage (and honestly the whole pack) assumes you're on SD1.5 - an SDXL checkpoint won't load it. Preview the uv_map and mask before the final inpaint; if the map looks scrambled, your mesh's UV layout is the thing to question, not the node.

CategoryPaint3D

Inputs (2)

NameTypeDefaultDescription
mesh_modelMESHMODEL
albedoIMAGE

Outputs (2)

NameTypeDescription
maskMASK
uv_mapIMAGE