SurfaceNets
public static class SurfaceNetsTurns a signed-distance field into a Mesh.
Naive surface nets over a regular grid. The field is sampled once at every grid corner; every cell whose corners disagree about the sign gets one vertex, at the mean of the points where the field crosses that cell's twelve edges; and every grid edge whose two ends disagree becomes two triangles joining the vertices of the four cells around it. No lookup tables, one vertex per cell, and near-uniform triangles that shade well and simplify well. Sharp creases come out rounded — the price of placing a vertex by averaging rather than by solving for the corner.
Normals come from the field, not from the triangles: the gradient of a distance function is its surface normal, so the shading is smooth at any resolution and the geometry can be coarse.
The result is deterministic — the same field, box and options give byte-identical arrays on every run and on any machine, because every pass is sequential and nothing depends on the thread count. What the box clips is left open: a field that crosses zero on the box's faces produces a surface with a hole there, and a field that never crosses zero inside the box produces an empty mesh.
Methods
| Member | Description |
|---|---|
| Finds the surface where
returns A mesh with positions, normals and indices; texture coordinates, tangents and colours when the options ask for them. Wound so the normals point out of the negative region. Empty, rather than null, when the field does not change sign inside the box. |