Closed Yeicor closed 2 years ago
After the latest optimizations it can now render a detailed mesh (of 972688 triangles) in a 129x96x106 cell grid in only 16 seconds, when previously this would take forever.
Note that this is the best case escenario in which the closest triangle's bounding box is enough to reconstruct the surface. Usually, more triangles are needed (for example 20 out of 366 triangles for the previous monkey model). I used an RTree built on load to quickly extract the nearest neighbors for each Evaluate() call.
Late to the party but hey, I'll drop this here in case it interest's yall: https://github.com/soypat/sdf/blob/main/helpers/sdfexp/import.go.
Left: original 128 cell on longest side model render using SDFs. 140k triangles
Right: Imported triangles using ImportModel
(from left model) and rendering using 128 cells on longest side. The resulting amount of triangles is near identical and model quality is preserved. 6.5s elapsed.
This allows importing triangle-based closed-surface meshes, solving #14. It could be optimized by filtering triangles on evaluation, but it is good enough for low poly meshes.
The new VoxelSdf SDF3 can be used both as a cache for slow evaluations (large SDF3 hierarchies) and SDF3 smoothing with trilinear interpolation (if its meshCells < renderer's meshCells for that bounding box).
New example (monkey_hat)
Original model (a slightly modified Suzanne from Blender --- eyes were different surfaces):
Result (without VoxelSdf and larger meshCells):