Nodes/Avatar Graph/Mesh Set Normals From Faces
ComfyUI Node

Mesh Set Normals From Faces

Fix shading glitches on generated geometry

By avatechai·Created 3 years ago·Updated 2 years ago· 264
Mesh Set Normals From Faces
  • BPY_OBJ
  • BPY_OBJ
keep_sharpfalse

The node you reach for when a mesh looks structurally fine but the shading is clearly wrong - dark patches, weird hard creases where there shouldn't be any, faces that read as inverted. It wraps Blender's real bpy.ops.mesh.set_normals_from_faces operator, part of Avatar Graph, the pack that runs actual Blender inside ComfyUI's process (via the bpy Python package) to build interactive 2D-to-3D avatars, auto-generating a node for every mesh operator Blender has.

How it works

Every vertex's shading normal ordinarily blends the normals of the faces around it, and that blend is what a renderer uses to fake smooth curvature on a mesh that's actually made of flat facets. When that data gets left stale or inconsistent - a common outcome after procedural mesh generation, extrusion, or any operation that adds geometry without properly updating normals - this operator throws it out and rebuilds it cleanly, purely from the current face data. It's a reset button for shading, not a geometry fix.

Inputs and output

  • BPY_OBJ - the mesh coming in.
  • keep_sharp (default false) - whether to preserve any existing sharp-edge markings (deliberate hard boundaries between smoothly-shaded regions) instead of smoothing everything uniformly. Leave it false for a clean, fully-smoothed reset; set it true if you've deliberately marked hard edges elsewhere in the graph and don't want this step to erase them.

Output is a single BPY_OBJ, normals recalculated.

Where it fits in this pack

Avatar Graph builds meshes from flat, segmented image layers, then extrudes and solidifies them into something with actual depth - a pipeline that's genuinely prone to leaving normals in an inconsistent state, since the geometry didn't exist as a clean, properly-oriented shape to begin with. This is the cleanup step worth running before a mesh goes into the live avatar viewer, where bad normals show up as visibly wrong lighting on an otherwise correct-looking model.

Installing it

ComfyUI Manager: search "avatar-graph-comfyui", install, restart. Manually: cd ComfyUI/custom_nodes && git clone https://github.com/avatechai/avatar-graph-comfyui, then cd avatar-graph-comfyui && python -m pip install -r requirements.txt, then restart.

Python 3.10.x is the requirement to nail down first - the bpy package this pack is built on needs that exact minor version, and the README recommends a dedicated conda environment on macOS/Linux (conda create --name comfyui python=3.10) rather than trusting an existing Python install. Windows users get a prebuilt ComfyUI + Python 3.10 zip linked in the README to unzip over their install before adding the pack via Manager. Restart with --enable-cors-header (macOS also wants --force-fp16) for the live 3D preview - without it, the graph still runs fine, you just save the model manually from the pack's Avatar Main Output node instead.

Common issues

Rule out the Python version first if this pack's nodes aren't loading. If shading is still visibly wrong after running this node, check the more fundamental issue first: face winding. This operator recalculates normals assuming your faces are already correctly oriented - it doesn't flip inside-out faces for you. If a chunk of your mesh looks inverted rather than just inconsistently shaded, that's a face-orientation problem this node won't solve on its own. And if you're losing intentional hard edges you set up elsewhere in the graph, that's keep_sharp defaulting to false - flip it true to preserve them.

Categoryblender

Inputs (2)

NameTypeDefaultDescription
BPY_OBJoptBPY_OBJ
keep_sharpoptBOOLEANfalse

Outputs (1)

NameTypeDescription
BPY_OBJBPY_OBJ