9

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.

torus


Update

Snail IQ

Snail SDF

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

aiekick instagram, aiekick twitter

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

  • 3
    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 04: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 05:09
  • @AndrewWilson thanks can you tell me how Aiekick Implemented Sdf to mesh? – Seyed Morteza Kamali Apr 16 '18 at 05:13
  • @AndrewWilson please see this video sdf generated by 2D plane?! – Seyed Morteza Kamali Apr 16 '18 at 05:19

2 Answers2

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.

Zesen Qian
  • 41
  • 2
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

then he could make the mesh easily:

SDF Mesher