cvlab-epfl/MeshUDF

Meshing Non-learned UDFs

nynyg opened this issue · 3 comments

nynyg commented

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!

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 commented

Thanks! Yes, that helps a lot!

@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)