How to fix flipped normals on an AI-generated model

Inward-facing triangles on a generated model show up as black patches, faces you can see through from one side and shading seams. Weld duplicate vertices so neighboring faces share edges, recalculate the normals to point outward and check the result with backface culling on. meshfx found 17,568 flipped faces on the generated wagon below, down to 0.

Generated wagon with 17,568 flipped faces on the source, marked in red as meshfx reports them, shown in three.js
Generated wagon with 17,568 flipped faces on the source, marked in red as meshfx reports them, shown in three.js

Why generated meshes have flipped normals

Generators extract the surface from a volume, and that step can wind some triangles the wrong way, most often in thin parts and where pieces overlap.

Engines draw only the front of each face, so an inward face disappears or renders black.

Non-manifold edges

meshfx also finds 1,470 non-manifold edges on this wagon. Fix them too, so the recalculated normals stay consistent.

Generated wagon with 1,470 non-manifold edges on the source, as meshfx counts them, shown in three.js
Generated wagon with 1,470 non-manifold edges on the source, as meshfx counts them, shown in three.js

Fix the normals by hand

  1. Turn on backface culling or a face orientation overlay to see which faces point inward.
  2. Merge vertices by distance so neighboring faces share edges. Some generators export every triangle with its own vertices.
  3. Recalculate normals outside on the whole mesh. See how to fix flipped normals for the command in each 3D tool.
  4. Flip any faces that still show inside out, one region at a time.
  5. Turn on smooth shading with an auto smooth angle near 30 degrees to remove faceting.
  6. Export a GLB with normals included and check it in your engine with backface culling on.

meshfx counts the flipped faces and the other faults and lists them in the report, so you know what to fix.

In three.js, Blender and Godot

Once you fix the faces in your editor, the GLB shades the same in all three, with no black patches or missing faces.

meshfx wagon with levels of detail, shown in three.js
Shown in three.js
meshfx wagon with levels of detail, shown in Blender
Shown in Blender
meshfx wagon with levels of detail, shown in Godot
Shown in Godot

Use with your agent

Paste the prompt into Claude Code, Cursor or Codex. Your agent connects to Spatial Compiler and comes back with a GLB and a report that counts the holes, flipped faces and non-manifold edges, so you know what to fix.

New accounts start with $5 of usage, and you see the price of each job before it runs.

Agent prompt

Connect the Spatial Compiler MCP server at https://spatialcompiler.dev/mcp if it isn't connected yet. Use meshfx to count the flipped faces and other faults in my generated model so I know what to fix. Run a Draft first. Your first 50 mesh Drafts are free with the $5 signup credit. Ask before running a final compile.

Or add the server yourself in Claude Code:

claude mcp add --transport http spatial-compiler https://spatialcompiler.dev/mcp

Set it up in Cursor, Codex or another agent

Generated model normals questions

All questions →

Why does my AI-generated model have black patches?

Some of its faces point inward. Engines draw only the front of each face, so those faces render black or disappear. Recalculate the normals outward to fix it.

Why does recalculating normals not fix my generated model?

The faces are often split apart, so each triangle has its own vertices. Merge vertices by distance first so neighboring faces share edges, then recalculate the normals.

Can I just make the material two-sided?

It hides the problem but doubles the pixel work on those faces and still lights them wrong. Fix the normals so the model renders correctly with backface culling on.