Nodes/ComfyUI-3D-MeshTool/Mesh_Optimization
ComfyUI Node

Mesh_Optimization

Cut a million triangles down to a renderable model

By 807502278·Created 2 years ago·Updated 2 years ago· 23
Mesh_Optimization
  • mesh
  • Mesh_Out
  • Face_Before
  • Face_After
Optimization_to0.65
algorithmTrue
remeshfalse
optimalplacementtrue

Photogrammetry and 3D-reconstruction outputs are beautiful and unusable: a million triangles that take forever to render and stream. Mesh Optimization is this pack's decimation node - the thing that takes that unwieldy mesh and makes it small enough to actually work with, while keeping the shape you care about. It's the node you reach for the moment a mesh comes out of a reconstruction step and you want to use it, not admire it.

The mechanism: it counts the current faces, applies your target percentage, and runs a mesh-decimation algorithm to get down to that many. The inputs:

  • mesh - a MESH from the pack's load/import nodes.
  • Optimization_to - a float from 0 to 1 (default 0.65), the fraction of faces to keep. 0.65 = keep 65%. Set it low (0.1) for aggressive decimation, close to 1 for a light touch.
  • algorithm - a boolean, and this one's a gotcha. True means pymeshlab, False means pyfqmr (Fast-Quadric-Mesh-Simplification). And here's the trap: the pack's own requirements.txt installs pyfqmr but not pymeshlab - yet the default is True. If you hit an import error on the default settings, flip algorithm off to use pyfqmr (the one that's actually installed), or pip install pymeshlab.
  • remesh (default off) - whether to remesh the result afterward, passed through to the decimation routine.
  • optimalplacement (default on) - the "keep it smooth" flag that lets vertices sit at optimal positions rather than locking to the old ones.

The outputs are Mesh_Out (the decimated MESH), plus Face_Before and Face_After as integers - your before/after triangle counts, which are the most satisfying pair of numbers in this pack. You get to see exactly what you saved.

Two things that will bite you. First, after decimation the pack wipes normals and UVs (it clears mismatched vertex data by design), so plan to re-run Auto Normal and re-unwrap UVs afterward if you need them. Second, decimation to a very low face count changes silhouettes - check the result in a preview before you bake a whole render pipeline on it.

It's part of the one-author 807502278/ComfyUI-3D-MeshTool pack, and MESH is a type from ComfyUI-3D-Pack, so keep that installed for sockets to resolve. Install:

cd ComfyUI/custom_nodes
git clone https://github.com/807502278/ComfyUI-3D-MeshTool
cd ComfyUI-3D-MeshTool
pip install -r requirements.txt   # kiui, xatlas, pyfqmr, plyfile

or via ComfyUI Manager (search "ComfyUI-3D-MeshTool"). And the pack's standing warning: node renames between releases turn old instances red - recreate and reconnect. If the default algorithm errors out on you, remember: flip to pyfqmr.

Category3D_MeshTool/optimization

Inputs (5)

NameTypeDefaultDescription
meshMESH
Optimization_toFLOAT0.650–1
algorithmBOOLEANTrue
remeshBOOLEANfalse
optimalplacementBOOLEANtrue

Outputs (3)

NameTypeDescription
Mesh_OutMESH
Face_BeforeINT
Face_AfterINT