I understand how to generate geometry using marching cubes at an isosurface, but I haven't been able to find a clear explanation on how to calculate the vertex normals for a mesh produced using marching cubes.
Right now, for each triangle generated during the lookup phase, I can calculate a face (not vertex) normal simply by taking the cross product of two of the vectors in the triangle ie:
Triangle = [p1, p2, p3];
normal[face] = (p2 - p1).cross(p3 - p1).normalized();
But how do I compute the vertex normals at p1
p2
and p3
to allow for smooth shading? The only way I can think of is to sample the density function to produce an estimate of its gradient -- but is there a faster way?