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

How to export tet-mesh? #12

Open
SophusDavid opened this issue Jan 11, 2024 · 4 comments
Open

How to export tet-mesh? #12

SophusDavid opened this issue Jan 11, 2024 · 4 comments

Comments

@SophusDavid
Copy link

SophusDavid commented Jan 11, 2024

thanks for your awesome work!
I noticed that in your paper you claim that flexicubes can extend to tet-mesh .I am interested in this .Could you tell me how to export a tet-mesh with flexicubes?

In flexicubes.py , the class of FlexiCubes there is a option to export tetmesh :

def __call__(self, x_nx3, s_n, cube_fx8, res, beta_fx12=None, alpha_fx8=None,
                 gamma_f=None, training=False, output_tetmesh=False, grad_func=None): 

but when i turn on it and run the optimize.py ,I found the rasterize method for tet-mesh have not implemented yet.

    v_pos_clip = xfm_points(mesh.vertices.unsqueeze(0), mvp)  # Rotate it to camera coordinates
    rast, db = dr.rasterize(
        dr.RasterizeGLContext(), v_pos_clip, mesh.faces.int(), iter_res)

this caused the error in nvdiffrast.

def rasterize(glctx, pos, tri, resolution, ranges=None, grad_db=True):

So how can i export and optimize a tet-mesh .

looking forward to some advise .

@frankshen07
Copy link
Collaborator

Hi @SophusDavid, the example we provided is not intended for tetmesh. You can first optimize using the triangular mesh, and once the shape is optimized, extract the tetrahedral mesh with output_tetmesh=True and then dump out the results. The triangular mesh and tetrahedral mesh would represent the same geometry since they are parametrized by the same field.

@seanxzhan
Copy link

Hi @frankshen07 , I ran optimize.py, and after 1000 iterations I also output the tetmesh (with output_tetmesh=True). The triangle mesh has converged, but the tetmesh looks like this. Do you know what could have gone wrong? Is there a way to train Flexicubes with tetmesh (render tetmesh during training)?

In the paper, Section 4.5 says "We augment FlexiCubes to additionally output a tetrahedral mesh when desired, which exactly conforms to the boundary of the extracted surface and supports automatic differentiation in the same sense as our surface extraction." So it sounds like there's a way to have the tetmesh conform to the trimesh.

broken_tetmesh

@frankshen07
Copy link
Collaborator

frankshen07 commented Sep 30, 2024

Hi @seanxzhan,

Thank you for reporting this issue. The problem is caused by a bug in the current published version of the code. Could you please try replacing the code at lines 464-465 with the following:

quad_vd_idx[flip_mask] = quad_vd_idx[flip_mask][:, [0, 1, 3, 2]]
quad_vd_idx[~flip_mask] = quad_vd_idx[~flip_mask][:, [2, 3, 1, 0]]

This should fix the problem, and we will update the code shortly.

@seanxzhan
Copy link

Hi @frankshen07 , thank you for your help! It works now!

image

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