Nodes/Avatar Graph/Create Mesh Layer
ComfyUI Node

Create Mesh Layer

Avatar Graph's core node for turning a segmented image into a mesh

By avatechai·Created 3 years ago·Updated 2 years ago· 264
Create Mesh Layer
  • image
  • BPY_OBJ
  • IMAGE
convex_hulltrue
shape_threshold0.70
mesh_layer_namemesh_layer
scale_x1.00
scale_y1.00
extrude_x0.00
extrude_y0.00
seed0

This is one of the actual documented nodes in Avatar Graph (avatechai/avatar-graph-comfyui), and it's central to what the pack does. Avatar Graph rigs a flat character image into a real-time interactive avatar - you segment the face (eyes, mouth, hair, whatever pieces you want to animate independently) with the pack's SAM node, then feed each segment into this node, which turns it into an actual Blender mesh object. The README's own description is blunt about it: "Create a mesh object from the input images (usually a segmented part of the entire image)." Everything downstream - shape keys, the Shape Flow runtime, the final avatar export - starts from a mesh this node produced.

How it works

You're not modeling anything by hand here. Given a segmented image (an eye cutout, say, with everything outside it transparent), the node traces the visible silhouette and builds a flat plane mesh shaped to match it, then generates UVs so the original image texture maps back onto that plane correctly. It's essentially "image cutout → textured flat geometry," which is exactly the building block Avatar Graph's rigging model needs: each face part becomes its own small mesh you can independently drive with shape keys later (an eye that blinks, a mouth that opens for lipsync).

The inputs and outputs that matter

  • image - the segmented input image. This is what actually gets converted; feed it a clean cutout, not the full uncropped character image, or the mesh will trace the wrong boundary.
  • convex_hull (default true) - whether the mesh outline follows a simplified convex hull around the visible pixels, versus a tighter contour that follows concave detail in the silhouette. Convex hull is cheaper and more robust for simple shapes like an eye or mouth; turn it off if you need the mesh to actually hug an irregular outline.
  • shape_threshold (default 0.7) - the cutoff used to decide what counts as "part of the shape" from the image's alpha/opacity, versus background. Push it lower to catch more of a faint or semi-transparent edge; push it higher to trim the mesh tighter to fully-opaque pixels.
  • scale_x / scale_y (default 1) and extrude_x / extrude_y (default 0) - sizing the resulting mesh and giving it some thickness along each axis, so it isn't perfectly paper-flat.
  • mesh_layer_name (default "mesh_layer") - what the resulting object gets called, useful for keeping multiple layers (eyes, mouth, brows) distinguishable downstream.
  • seed (default 0) - controls whatever randomized step is involved in contour simplification; change it if a mesh outline comes out oddly for a given image and a different seed gives a cleaner result.

Outputs: BPY_OBJ, the new mesh object - feed this into shape-key nodes, constraints, or eventually Avatar Main Output - and IMAGE, the processed image passed back out for previewing or further use.

How to install it

Via ComfyUI Manager: search "avatar-graph-comfyui", install, restart. Or clone it 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 node runs through bpy, the whole pack needs Python 3.10.x - nothing later. Windows users get a prebuilt Python 3.10 ComfyUI zip from the README for this exact reason; on Mac/Linux, build a dedicated conda env (conda create --name comfyui python=3.10) instead of fighting your existing one. Restart with --enable-cors-header afterward so the live avatar preview panel can talk to editor.avatech.ai - you can skip it if you only care about file exports.

Common issues & troubleshooting

The install is the fragile part. Because bpy needs Python 3.10 specifically, dropping this pack into a 3.11/3.12 environment - the default on most current ComfyUI installs - fails outright, and there's a real report of Avatar Graph leaving a ComfyUI Desktop install badly broken after installing it (an oversized UI logo, an unwanted audio-permission popup) badly enough that a full reinstall didn't clean it up. Test it in a spare, portable ComfyUI instance first if you're not already isolated on 3.10.

For the node itself: the README's own best-practice advice matters here - it recommends a character image at least 768x768 with an open mouth and clearly visible facial features, specifically so segmentation (and by extension this node's shape tracing) has enough resolution and contrast to work with. If a mesh comes out with a jagged or wrong-looking outline, check shape_threshold first - a segmented image with soft or semi-transparent edges will trace inconsistently at the default cutoff. And if convex_hull is on but you needed a concave shape (a crescent-shaped eye segment, for instance), turning it off is usually the fix, not fiddling with scale or extrude.

Categoryblender

Inputs (9)

NameTypeDefaultDescription
imageoptIMAGE
convex_hulloptBOOLEANtrue
shape_thresholdoptFLOAT0.70
mesh_layer_nameoptSTRINGmesh_layer
scale_xoptFLOAT1.00
scale_yoptFLOAT1.00
extrude_xoptFLOAT0.00
extrude_yoptFLOAT0.00
seedoptINT00–18446744073709550000

Outputs (2)

NameTypeDescription
BPY_OBJBPY_OBJ
IMAGEIMAGE