Nodes/Avatar Graph/Mesh Paint Mask Slice
ComfyUI Node

Mesh Paint Mask Slice

Cutting a mesh down to the part your segmentation mask kept

By avatechai·Created 3 years ago·Updated 2 years ago· 264
Mesh Paint Mask Slice
  • BPY_OBJ
  • BPY_OBJ
mask_threshold0.50
fill_holestrue
new_objecttrue

Unlike most of the other Mesh_* nodes in this pack, this one isn't a stock Blender operator wearing a ComfyUI node's clothes - the name doesn't match anything in Blender's own bpy.ops.mesh namespace. It's custom to Avatech, and it fits neatly into the specific pipeline this whole pack was built for: turning a segmented piece of a character image into a clean, isolated mesh.

What it is and why you'd reach for it

Avatar Graph's documented flow starts with a SAM-based segmentation node that lets you carve out parts of a source image - an eye, a mouth, a whole face plane - as separate masks, which then get built into mesh objects. But a raw mask rarely maps to a clean cut: edges are soft, thresholds are fuzzy, and there can be small holes inside the region you meant to keep. This node takes that mask data and actually slices the mesh geometry to match it, which is the step between "I have a mask" and "I have a mesh object that's just the eye." It's the kind of node you'd reach for right after building a mesh layer from a segmented image, before you start rigging shape keys onto it.

How it works

Given a threshold, it decides which parts of the mesh count as "inside" the mask versus "outside," cuts the geometry along that boundary, and can optionally patch over small gaps left by noisy mask edges before deciding whether to keep the result as a separate object or fold it back into what you had.

The inputs and outputs that matter

Three fields, all genuinely worth understanding before your first run:

  • mask_threshold (0–1, default 0.5) - where the mask's soft edge gets treated as a hard cutoff. Push it up if your slice is grabbing a bit too much of the surrounding area; pull it down if it's cutting away part of the region you meant to keep.
  • fill_holes (boolean, default on) - patches small interior gaps that a noisy or imperfect mask can leave behind. Leave this on unless you specifically need those holes preserved.
  • new_object (boolean, default on) - whether the sliced result becomes its own separate mesh object, or replaces geometry in place on the object you fed in. On is what you want if you're isolating a part (an eye, a mouth) to rig independently.

Output is the usual single BPY_OBJ.

How to install it

ComfyUI Manager: search Avatar Graph, install, restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/avatechai/avatar-graph-comfyui
cd avatar-graph-comfyui
python -m pip install -r requirements.txt

Because this pack depends on bpy - Blender packaged as a Python module, which only ships wheels for specific minor versions - the README is explicit that you need Python 3.10.x, not "whatever ComfyUI happens to be running." Windows users can grab the pack's own embedded-Python-3.10 zip instead of fighting their existing environment; macOS/Linux users should set up a pinned conda create --name comfyui python=3.10 env first. Launch with --enable-cors-header (add --force-fp16 on Mac) if you want the real-time avatar viewer talking to editor.avatech.ai - that's the panel people used to turn a static face image into something that visibly blinks and lipsyncs, the kind of demo that made the rounds when this project first showed up on r/StableDiffusion.

Common issues

A slice that grabs way too much or way too little of the mesh is almost always a mask_threshold problem before it's a mask problem - nudge it in 0.1 increments rather than assuming the segmentation upstream was wrong. Jagged or torn-looking edges after slicing usually mean fill_holes needs to be on, or that the source mask itself has noise worth cleaning up before it reaches this node. And as always with this pack, if bpy won't install, check python --version first - 3.10.x or nothing.

Categoryblender

Inputs (4)

NameTypeDefaultDescription
BPY_OBJoptBPY_OBJ
mask_thresholdoptFLOAT0.500–1
fill_holesoptBOOLEANtrue
new_objectoptBOOLEANtrue

Outputs (1)

NameTypeDescription
BPY_OBJBPY_OBJ