# 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). – Andrew Wilson Apr 15 '18 at 22:53
• @AndrewWilson yeah that's right marching cubes Is solution but I haven't Idea to Implement this algorithm In Raymarching – Seyed Morteza Kamali Apr 16 '18 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). – Andrew Wilson Apr 16 '18 at 5:09
• @AndrewWilson thanks can you tell me how Aiekick Implemented Sdf to mesh? – Seyed Morteza Kamali Apr 16 '18 at 5:13
• @AndrewWilson please see this video sdf generated by 2D plane?! – Seyed Morteza Kamali Apr 16 '18 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. – Seyed Morteza Kamali Apr 16 '18 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? – user2153553 Sep 12 '18 at 2:35
• @user2153553 this software is made by person in twitter I don't know Is it available right now but you can ask more about this software – Seyed Morteza Kamali Sep 12 '18 at 7:28
• Yes I actually have been following that guy also, he said it's coming soon. – user2153553 Sep 13 '18 at 0:10
• really interesting software indeed, it seems the author will be selling it on steam – BPL Jun 19 '19 at 8:40