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

Meshing Non-learned UDFs #6

Open
nynyg opened this issue Jan 8, 2024 · 3 comments
Open

Meshing Non-learned UDFs #6

nynyg opened this issue Jan 8, 2024 · 3 comments

Comments

@nynyg
Copy link

nynyg commented Jan 8, 2024

Thanks a lot for the awesome contribution to the community!

I understand that the context of the project is more relevant to learned UDFs. However, I wonder if / how we can mesh an exact UDF (e.g., a HxWxD tensor) using the tools you provide?

Thanks a lot!

@bguillard
Copy link
Collaborator

Hello,
Yes you can use our meshing procedure on an exact UDF, provided you also have their spatial gradients. We tried and discussed it in the supplementary (Sec. 5.4): with an exact UDF, most artefacts disappear (holes, staircases...).

You can simply pass your exact UDF values and their gradients to udf_mc_lewiner:

from _marching_cubes_lewiner import udf_mc_lewiner

udf_values = np.array(...)
gradients = np.array(...)
voxel_size = ...

verts, faces, _, _ = udf_mc_lewiner(udf_values,
                                    gradients,
                                    spacing=[voxel_size] * 3)

Hope it helps,
Benoit

@nynyg
Copy link
Author

nynyg commented Jan 19, 2024

Thanks! Yes, that helps a lot!

@HochCC
Copy link

HochCC commented Sep 5, 2024

@bguillard hi, thanks for sharing your great work. May I ask, how to compute gradients?
I use following code to compute grad from a real udf field (from mesh, normed in [0, 1]), howere, I got wire result.

grad_x, grad_y, grad_z = np.gradient(udf) 
gradients = np.stack([grad_x, grad_y, grad_z], axis=-1) # (v v v 3)
# optional, gradients=norm(gradients)
verts, faces, _, _ = udf_mc_lewiner(udf, -gradients, spacing=[2.0 / (vol_resolution - 1)] * 3)

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

No branches or pull requests

3 participants