Nodes/Avatar Graph/Object Vertex Group Clean
ComfyUI Node

Object Vertex Group Clean

Sweeping out the near-zero weights nobody asked for

By avatechai·Created 3 years ago·Updated 2 years ago· 264
Object Vertex Group Clean
  • BPY_OBJ
  • group_select_mode
  • BPY_OBJ
limit0.00
keep_singlefalse

Weight painting is messy. Tools add stray vertices to groups at weights like 0.002, and those near-zero weights silently bloat your mesh data, slow down deformation, and can cause weird "why is this vertex twitching" moments. Object Vertex Group Clean is the sweep: it walks the active group's vertices and removes any whose weight is below a threshold, wrapping the Blender operator bpy.ops.object.vertex_group_clean().

The threshold is the limit input - a float from 0 to 1, default 0, meaning "only remove true zero-weight vertices." The useful setting is somewhere above zero, like 0.01, so you purge the noise but keep the real influence. There's also keep_single (default false): when on, it ensures every vertex stays in at least one group even if its best weight falls below the limit - important on rigged meshes where every vertex needs some group or it stops deforming. And group_select_mode decides which groups get cleaned (active group, all groups, etc.) - that one's a B_ENUM input.

The B_ENUM thing deserves a moment because it shows up across several vertex-group nodes. group_select_mode isn't a plain dropdown in ComfyUI - it's the pack's custom "ENUM (Blender)" type, which is just a string you pass through that gets resolved against Blender's operator enum at runtime. In the editor you'll see a socket rather than a widget; wire the pack's ENUM (Blender) node into it with the identifier string. Leave it unwired and the operator falls back to its default, which for most of these ops targets the active group - usually fine for a clean-up step.

BPY_OBJ in, BPY_OBJ out - the same object, with the dross removed.

In the avatar pipeline, this is the hygiene step before you hand groups to shape keys or export: a blink shape key driven by a group with 50 phantom 0.001-weight vertices behaves subtly worse than one that's been cleaned. Run it late, after the group's weights are settled.

Install is pack-wide: ComfyUI Manager → "Avatar Graph", or git clone https://github.com/avatechai/avatar-graph-comfyui into ComfyUI/custom_nodes and pip install -r requirements.txt on Python 3.10 (bpy==3.6.0). First launch downloads the ~2.4 GB SAM model.

Troubleshooting: set limit too high (say 0.3) and you'll strip legitimate influence and the mesh stops deforming right - start at 0.01 and creep up. If you notice a group getting emptied entirely, that's keep_single off doing its thing; flip it on if the mesh has no fallback group. And as always in this pack, the scene rebuilds each run, so clean-up is per-run - which is fine, because the mess is per-run too.

Categoryblender

Inputs (4)

NameTypeDefaultDescription
BPY_OBJoptBPY_OBJ
group_select_modeoptB_ENUM
limitoptFLOAT0.000–1
keep_singleoptBOOLEANfalse

Outputs (1)

NameTypeDescription
BPY_OBJBPY_OBJ