NVlabs / nvdiffrec

Official code for the CVPR 2022 (oral) paper "Extracting Triangular 3D Models, Materials, and Lighting From Images".
Other
2.09k stars 222 forks source link

Question about DMTet #131

Open bychen7 opened 1 year ago

bychen7 commented 1 year ago

Thank you for your code. Recently, while studying your work on the implementation of DMTet code, I have some questions and would appreciate your response. Specifically:

https://github.com/NVlabs/nvdiffrec/blob/e7f2181b8a60eb8fedcdb4ad4d05bff3c0cf9bc1/geometry/dmtet.py#L23

https://github.com/NVlabs/nvdiffrec/blob/e7f2181b8a60eb8fedcdb4ad4d05bff3c0cf9bc1/geometry/dmtet.py#L42

https://github.com/NVlabs/nvdiffrec/blob/e7f2181b8a60eb8fedcdb4ad4d05bff3c0cf9bc1/geometry/dmtet.py#L43

JHnvidia commented 1 year ago

HI @blackmagicianZ,

triangle_table enumerates the standard marching tetrahedra cases. Based on the sign of the SDF in each tet-corner there's a total of 4^2 =16 (4 corners, 2 signs) that the level-set surface can pass trough the tetrahedra. In some cases the surface is a triangle, and in some cases a quad. The quad cases result in 2 triangles, as indicated by the num_triangles_table. The values in triangle_table indices the tet-edge where surface vertices are inserted, in the order indicated by base_tet_edges.

There's a picture of the marching tet cases here (reduced to 8 symmetric cases): https://daac.hpc.mil/gettingStarted/images/MarchingTets.gif

Your intuition for for base_tet_edgesis correct, just that triangle_table index tet-edges and not tet-vertices. That's because triangle/surface vertices are inserted where an edge intersects the level-set (SDF=0).

bychen7 commented 1 year ago

@JHnvidia Thank you for your response. I roughly understand that the first row [1, 0, 2, -1, -1, -1] in the triangle_table represents selecting the three edges (0,1), (0,2), and (0,3) from base_tet_edges, and [2, 0, 1, -1, -1, -1] is the symmetric case. How was the order of 1, 0, and 2 determined in the first row? Can it be any order?

JHnvidia commented 1 year ago

The order is mostly flexible, but all tables are connected and must be consistent with a right handed coordinate system and counter clockwise winding rules.

bychen7 commented 1 year ago

@JHnvidia Thank you for your patient response, but I still don't understand why it is necessary to comply with the right-hand coordinate system and counterclockwise winding rule, and I haven't found a symmetrical pattern. How was triangle_table written row by row according to the image in the link?

frankshen07 commented 11 months ago

Hi @bychen7, the table is constructed in such a way that all extracted triangles have their normal points facing outward, with the assumption that the negative SDF represents the "inside" of the object. You can work with a different convention, but it's crucial to ensure that the windings are consistent, and the normals are correct when passing the mesh into diff-render. Hope this answers your question!

ug-kim commented 4 months ago

Hi @JHnvidia, can you give me the correct URL for marching test cases? Before one is https://daac.hpc.mil/gettingStarted/images/MarchingTets.gif, but I cannot connect to this URL.