tdhooper / glsl-marching-cubes

WebGL Signed Distance Function Mesher

Home Page:http://tdhooper.github.io/glsl-marching-cubes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

WebGL Signed Distance Function Mesher

Extract an STL from a glsl distance function

http://tdhooper.github.io/glsl-marching-cubes/

Limitations

  • 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.

About

WebGL Signed Distance Function Mesher

http://tdhooper.github.io/glsl-marching-cubes

License:GNU General Public License v3.0


Languages

Language:JavaScript 98.4%Language:CSS 0.8%Language:GLSL 0.5%Language:HTML 0.4%