Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert triangle meshes to SDF3 and voxel-based cache/smoothing #44

Merged
merged 4 commits into from
Jan 9, 2022

Conversation

Yeicor
Copy link
Contributor

@Yeicor Yeicor commented Jan 1, 2022

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):
Screenshot_20220101_010431

Result (without VoxelSdf and larger meshCells):
Screenshot_20220101_010435

@Yeicor
Copy link
Contributor Author

Yeicor commented Jan 8, 2022

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.

Screenshot_20220108_192927

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.

@deadsy deadsy merged commit 61c1232 into deadsy:master Jan 9, 2022
@Yeicor Yeicor deleted the import-stl branch January 10, 2022 19:02
@soypat
Copy link
Contributor

soypat commented May 18, 2022

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.
image

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants