Skip to content
WebGL Signed Distance Function Mesher
Branch: gh-pages
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
spec/support Split volumes that don't fix the max texture size into smaller blocks Feb 5, 2016
package.json Stop cursor being reset when editing bounds in code Feb 20, 2016

WebGL Signed Distance Function Mesher

Extract an STL from a glsl distance function


  • Large meshes will be saved in parts, you can re-combine them with MeshLab
  • You might get some missing triangles (holes) in the mesh

If you have a Mac, check out F3 which does this a LOT better.

Tools used

How does it work?

It follows the basic marching cubes algorithm, except distances for each cube vertex are extracted from the shader first1, to reduce the number of GPU/CPU round trips.

The volume to be marched is subdivided into blocks small enough to fit the maximum texture size. As distances are extracted first, any blocks which are entirely inside (negative) or outside (positive) the surface are skipped, saving some time for models with a lot of empty space.

I tried running the entire marching cubes algorithm on the GPU, but the cost and difficulty of getting data back onto the CPU made it far too slow.

The JavaScript marching cubes implementation this is based on2 runs much faster for simple models. I haven’t compared them for more complex models.

You can’t perform that action at this time.