YueJiang-nj / CVPR2020-SDFDiff

SDFDiff: Differentiable Rendering of Signed Distance Fields for 3D Shape Optimization
275 stars 19 forks source link

How is grid_normal computed? #5

Closed Kai-46 closed 3 years ago

Kai-46 commented 3 years ago

Thanks for sharing the source code!

I have a question regarding how the grid_normal is computed at here. To compute the grid_normal for a grid vertex with central finite difference, I was expecting that the 6 adjacent vertices will be used. However, the code seems to be doing something different? Could you please explain a bit more?

In addition, if the grid_normal of a grid vertex involves 6 adjacent vertices, then the normal at intersection point involves 8x6-8x2=32 vertices? 8x6 is because the normal at intersection point is acquired by trilinearly interpolating the grid_normal of its 8 closest vertices; subtracting 8x2 is because each of these 8 closest vertices is counted three times. However, the paper says 4x4x4=64 vertices are involved. Am I missing something? Could you please elaborate?

Thank you!

YueJiang-nj commented 3 years ago

I just used 2 vertices next to the target grid position. The next one minus the previous one, then divided by 2 * voxel size. This is just used to compute normals on the grid. After getting all the normals on the grid, then we do trilinear interpolation.

Kai-46 commented 3 years ago

Thanks for the replies. That aligns with what I was thinking. So in this case, each vertex normal uses sdf values of 6 adjacent vertices (front-behind, left-right, up-bottom), right? To compute the vertex normals for the 8 vertices of a voxel, one needs to use sdf values of a total 8x6-8x2=32 vertices?

YueJiang-nj commented 3 years ago

I think that's correct.

Kai-46 commented 3 years ago

Thank you for confirming!