gradientspace / geometry3Sharp

C# library for 2D/3D geometric computation, mesh algorithms, and so on. Boost license.
http://www.gradientspace.com
Boost Software License 1.0
1.69k stars 380 forks source link

Adaptive tessellation #159

Open 48design opened 3 years ago

48design commented 3 years ago

Has someone implemented adaptive tessellation/subdivision that can be used with this library? I don't know where to start.

The remeshing class is awesome but it would be perfect to specify vertices (like constraints) or to use the boundaries to allow smaller edge lengths when getting closer. This way one could better reproduce fine details.

I tried a naive approach by iteratively splitting edges one ring around the boundaries but the control I was getting on how the edges align isn't that great and the resulting meshes are not really useful this way.

rms80 commented 3 years ago

The Remesher supports point and edge constraints, see this blog post for more details: https://www.gradientspace.com/tutorials/2018/7/5/remeshing-and-constraints

But it sounds like you mean something more like "weights" than "constraints". One way to do this is to make the Remesher MinEdgeLength/MaxEdgeLength something you compute relative to the local geometry (in Remesher::ProcessEdge), instead of fixed constants. So for example you could compute the deviation in normals between the vertices/faces/etc that are being processed, and use that to modulate a fixed min/max edge length. This kind of thing works pretty well. Another more flexible way is to precompute a 'weight map' ahead of time and store it in the mesh vertex colors, and then sample that to determine the target density.

48design commented 3 years ago

Thank you very much for your answer.

The project I need this for has been on hold since I asked this question. I managed to make a little progress then, but wasn't really satisfied with the results. I have already pre-calculated the border distance for each vertex, but couldn't figure out where exactly I need to use this.