# How can I convert signed distance field to a mesh?

I can easily make models by Modeling with Distance Functions but I need make mesh from It so I decide to use voxelizing and make triangles for my signed distance field torus like this video.but I haven't Idea that how can I do this. you can see this torus on my github.

# Update

Snail SDF

I found a software as SDF Mesher.this is what I want but not released.

he converted shader to mesh?! how could be Implemented!?

aiekick sketchfab

In short I need a way to convert sdf to mesh.for example this:

Input : SDF Model

Output : Mesh

• An easier to implement algorithm would be Marching Cubes. Though it would produce worse results than dual contouring for a torus. It would likely be easier to understand dual contouring after implementing marching cubes. Or use one of the thousand implementations of it in libraries like VTK or CGAL. Also marching cubes is easily understood in 2d (called marching squares). Apr 15, 2018 at 22:53
• @AndrewWilson yeah that's right marching cubes Is solution but I haven't Idea to Implement this algorithm In Raymarching Apr 16, 2018 at 4:38
• Oh, I think I get what you mean now. But ray marching is completely unrelated to the generation and usage of the polygon. Marching cubes produces a polygon from a 3d image (voxel grid/scalar field). You should create a 3d image of a resolution you want and evaluate the signed distance function at every point in the image to create a signed distance field. Then use 0 as your threshold (ie surface is at 0). Apr 16, 2018 at 5:09
• @AndrewWilson thanks can you tell me how Aiekick Implemented Sdf to mesh? Apr 16, 2018 at 5:13
• @AndrewWilson please see this video sdf generated by 2D plane?! Apr 16, 2018 at 5:19

with CGAL you can generate mesh by implicit function. https://doc.cgal.org/latest/Mesh_3/index.html

Search for "implicit". There is an example of generating meshes from the funciton of a sphere.

• I don't need this.what I want Is a scanner that scan my Raymarching objects then create the mesh from It. Apr 16, 2018 at 5:28

After many research I figured out how it works:

he defined three buffer in glsl and i get 3 sampler2D for multipass, in each fbo attachments. the params are (buffer : file : id) file is the targeted shader, here we want the current so no file. id is the fbo attachment (0 to 7).

then he could make the mesh easily:

• What software is this? Is it available right now? Sep 12, 2018 at 2:35
• Yes I actually have been following that guy also, he said it's coming soon. Sep 13, 2018 at 0:10
• really interesting software indeed, it seems the author will be selling it on steam
– user4801
Jun 19, 2019 at 8:40