ComfyUI Node

CV2 Inpaint Texture

The fast, free way to patch the holes in your baked 3D texture

By kijai·Created 2 years ago·Updated 5 months ago· 1,033
CV2 Inpaint Texture
  • texture
  • mask
  • texture
inpaint_radius3
inpaint_methodns

Every Hunyuan3D texture bake leaves gaps. When Hy3DBakeFromMultiview projects your six multi-view renders back onto the mesh, some pixels just never get covered - occluded nooks, the underside, places the camera ring never saw. Those come back as black or muddy smudges on the UV map, and CV2InpaintTexture is the cheap, cheerful way to fill them.

It's the OpenCV inpainting utility in this pack, and "utility" is the operative word. It takes your texture image and a mask, runs cv2.inpaint, and hands back a cleaned texture. That's the whole node. No model, no VRAM spike, no new download.

The one input to get right

The mask semantics trip people up, because the node inverts the mask internally. Feed it the mask that marks the good, covered areas - which is exactly what Hy3DBakeFromMultiview outputs as its second socket. The node flips it to find the holes and fills those. If you feed an inverted mask instead, you'll inpaint the good texture and leave the holes alone. If your result looks worse than what you put in, that's almost certainly it.

  • inpaint_radius (default 3) - how many pixels out from the mask edge to blend. 3 is fine for most bakes; bump it if seams stay visible.
  • inpaint_method - ns (Navier-Stokes) or telea. Both ship with OpenCV. ns is the default and generally smoother for these soft missing-area fills; telea is faster and a little more "smear-y". At this scale you'd be hard pressed to blind-test the difference.

Output is a single texture (IMAGE), which you can wire straight into Hy3DApplyTexture if you're done, or into the heavier Hy3DMeshVerticeInpaintTexture if you want a smarter pass first.

Where it fits

This is the two-tier ending of the texture chain. Fast tier: bake → CV2InpaintTexture → apply → export. Better tier: bake → Hy3DMeshVerticeInpaintTexture (which understands the mesh geometry and spreads colors across the actual surface, at the cost of a compiled extension and slower runs) → CV2InpaintTexture for the final polish → apply.

For a 3D print or a static prop, the plain CV2 pass is usually enough and it's nearly instant. The vertex inpaint is worth it when the missing areas are large and you can see the smear in a render.

Install and gotchas

The node ships with the pack, so it comes along when you install kijai's wrapper - ComfyUI Manager, search "Hunyuan3DWrapper", or:

cd ComfyUI/custom_nodes && git clone https://github.com/kijai/ComfyUI-Hunyuan3DWrapper

opencv-python is in the pack's requirements.txt, so once the pack imports, this node imports. Where people get burned is not the node itself but the rest of the texture chain: the multi-view bake that feeds it depends on the compiled custom_rasterizer wheel (Windows 11 / Python 3.12 / CUDA 12.6). If Hy3DRenderMultiView or the bake throws No module named 'custom_rasterizer', no amount of inpainting will help - fix the rasterizer install first, then come back here.

Don't expect magic: CV2 inpainting smears plausible color across holes. It won't invent a texture that was never baked. For big missing regions you're better off feeding the vertex inpaint first, or re-baking with more camera views via Hy3DCameraConfig.

CategoryHunyuan3DWrapper

Inputs (4)

NameTypeDefaultDescription
textureIMAGE
maskMASK
inpaint_radiusINT31–10
inpaint_methodCOMBOns2 options: ns, telea

Outputs (1)

NameTypeDescription
textureIMAGE