<p>with CGAL you can generate mesh by implicit function. <a href="https://doc.cgal.org/latest/Mesh_3/index.html" rel="nofollow noreferrer">https://doc.cgal.org/latest/Mesh_3/index.html</a></p>

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

CC BY-SA 3.0
2018-04-16T05:28:02.460Z
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
CC BY-SA 3.0
2018-04-15T19:50:22.117Z
2018-04-15T19:50:22.117Z
Zesen Qian
<p>After many research I figured out how it works:</p>

<p>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).
<a href="https://i.sstatic.net/byRkM.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/byRkM.png" alt="Result"></a></p>

<p>then he could make the mesh easily:</p>

<p><img src="https://user-images.githubusercontent.com/16706911/38791232-cfe1def2-415b-11e8-8961-d93c06dd87d4.gif" alt="SDF Mesher"></p>

CC BY-SA 4.0
2018-09-12T02:35:05.263Z
What software is this? Is it available right now?
user2153553
CC BY-SA 4.0
2018-09-12T07:28:50.043Z
@user2153553 this software is made by [person in twitter](https://twitter.com/hashtag/sdfmesher) I don't know Is it available right now but you can ask more about this software
Seyed Morteza Kamali
CC BY-SA 4.0
2018-09-13T00:10:45.490Z
Yes I actually have been following that guy also, he said it's coming soon.
user2153553
CC BY-SA 3.0
2018-04-16T06:00:59.563Z
2018-04-16T06:00:59.563Z
Seyed Morteza Kamali
<p>I can easily make models by <a href="http://iquilezles.org/www/articles/distfunctions/distfunctions.htm" rel="noreferrer">Modeling with Distance Functions</a> but I need make mesh from It so I decide to use voxelizing and make triangles for my <a href="https://www.gamasutra.com/blogs/DavidArppe/20170405/295240/How_to_get_Stunning_Graphics_with_Raymarching_in_Games.php" rel="noreferrer">signed distance field torus</a> like <a href="https://www.youtube.com/watch?v=B_xk71YopsA" rel="noreferrer">this video</a>.but I haven't Idea that how can I do this.
you can see this torus on <a href="https://github.com/smkplus/UnityRayMarching" rel="noreferrer">my github</a>.</p>
<p><a href="https://i.sstatic.net/jF5Ng.png" rel="noreferrer"><img src="https://i.sstatic.net/jF5Ng.png" alt="torus" /></a></p>
<hr />
<h1>Update</h1>
<p><a href="https://i.sstatic.net/YoSlj.png" rel="noreferrer"><img src="https://i.sstatic.net/YoSlj.png" alt="Snail IQ" /></a></p>
<p><a href="https://www.shadertoy.com/view/ld3Gz2" rel="noreferrer">Snail SDF</a></p>
<p>I found a software as <strong>SDF Mesher</strong>.this is what I want but not released.</p>
<p><a href="https://www.instagram.com/aiekick/" rel="noreferrer">aiekick instagram</a>,
<a href="https://twitter.com/hashtag/sdfmesher" rel="noreferrer">aiekick twitter</a></p>
<p>he converted shader to mesh?! how could be Implemented!?</p>
<p><a href="https://sketchfab.com/Aiekick" rel="noreferrer">aiekick sketchfab</a></p>
<hr />
<p>In short I need a way to convert sdf to mesh.for example this:</p>
<p>Input : <a href="https://www.shadertoy.com/view/4tc3WB" rel="noreferrer">SDF Model</a></p>
<p>Output : <a href="https://sketchfab.com/models/e1ebf9fcd38444d88e45f84204781db9" rel="noreferrer">Mesh</a></p>

CC BY-SA 3.0
2018-04-15T22:53:55.777Z
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
CC BY-SA 3.0
2018-04-16T04:38:10.713Z
@AndrewWilson yeah that's right [marching cubes](https://www.youtube.com/watch?v=B_xk71YopsA) Is solution but I haven't Idea to Implement this algorithm In Raymarching
Seyed Morteza Kamali
CC BY-SA 3.0
2018-04-16T05:09:23.300Z
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
CC BY-SA 3.0
2018-04-16T05:13:07.823Z
@AndrewWilson thanks can you tell me how Aiekick Implemented [Sdf to mesh](https://sketchfab.com/Aiekick)?
Seyed Morteza Kamali
CC BY-SA 3.0
2018-04-16T05:19:56.167Z
@AndrewWilson please see this [video](https://twitter.com/twitter/statuses/984221543705251840) sdf generated by 2D plane?!
Seyed Morteza Kamali
<glsl><mesh><raymarching>
How can I convert signed distance field to a mesh?
Seyed Morteza Kamali
# How can I convert signed distance field to a mesh?

(Asked by: username_0 on 2018-04-15)

I can easily make models by [Modeling with Distance Functions](http://iquilezles.org/www/articles/distfunctions/distfunctions.htm) but I need make mesh from It so I decide to use voxelizing and make triangles for my [signed distance field torus](https://www.gamasutra.com/blogs/DavidArppe/20170405/295240/How_to_get_Stunning_Graphics_with_Raymarching_in_Games.php) like [this video](https://www.youtube.com/watch?v=B_xk71YopsA).but I haven't Idea that how can I do this.
you can see this torus on [my github](https://github.com/smkplus/UnityRayMarching).

[![torus](https://i.sstatic.net/jF5Ng.png)](https://i.sstatic.net/jF5Ng.png)

---

# Update

[![Snail IQ](https://i.sstatic.net/YoSlj.png)](https://i.sstatic.net/YoSlj.png)

[Snail SDF](https://www.shadertoy.com/view/ld3Gz2)

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

[aiekick instagram](https://www.instagram.com/aiekick/),
[aiekick twitter](https://twitter.com/hashtag/sdfmesher)

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

[aiekick sketchfab](https://sketchfab.com/Aiekick)

---

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

Input : [SDF Model](https://www.shadertoy.com/view/4tc3WB)

Output : [Mesh](https://sketchfab.com/models/e1ebf9fcd38444d88e45f84204781db9)

**Tags:** glsl, mesh, raymarching

> **Comments:**
> **username_1**: 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).  
> **username_0**: @username_1 yeah that's right [marching cubes](https://www.youtube.com/watch?v=B_xk71YopsA) Is solution but I haven't Idea to Implement this algorithm In Raymarching  
> **username_1**: 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).  
> **username_0**: @username_1 thanks can you tell me how Aiekick Implemented [Sdf to mesh](https://sketchfab.com/Aiekick)?  
> **username_0**: @username_1 please see this [video](https://twitter.com/twitter/statuses/984221543705251840) sdf generated by 2D plane?!  

---

## 2 answers

### Answer by username_2 on 2018-04-15. Score: 3

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.

> **Comments:**
> **username_0**: I don't need this.what I want Is a scanner that scan my Raymarching objects then create the mesh from It.  

---

### Answer by username_0 on 2018-04-16. Score: 2

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).
[![Result](https://i.sstatic.net/byRkM.png)](https://i.sstatic.net/byRkM.png)

then he could make the mesh easily:

![SDF Mesher](https://user-images.githubusercontent.com/16706911/38791232-cfe1def2-415b-11e8-8961-d93c06dd87d4.gif)

> **Comments:**
> **username_3**: What software is this? Is it available right now?  
> **username_0**: @username_3 this software is made by [person in twitter](https://twitter.com/hashtag/sdfmesher) I don't know Is it available right now but you can ask more about this software  
> **username_3**: Yes I actually have been following that guy also, he said it's coming soon.  

---

