API Reference · Geometry

SurfaceNetsOptions

Namespace: Ava3D

public sealed class SurfaceNetsOptions

What SurfaceNets.Extract is given beyond the field, the box and the resolution. Every property has a default that produces a plain, closed, smoothly shaded mesh with positions, normals and indices and nothing else.

Properties

MemberDescription
Func<Vector3, Vector4> Color { get; set; }

A vertex colour for a point on the surface, called once per vertex. Null means no vertex colours. This is Mesh.Colors: a tint multiplied into the material, white being the identity.

Func<Vector3, Vector3> Gradient { get; set; }

The field's gradient at a point, which is the surface normal there. Null means central differences on the field itself, half a cell either side — six more evaluations per vertex. Give the analytic gradient when it is cheap, or when the field is not smooth at the cell scale. The result is normalised before use; a zero or non-finite gradient falls back to the average of the faces around the vertex.

int MaxTriangles { get; set; }

The most triangles the result may have. The count is known before anything is allocated, so a field that would exceed it throws SurfaceNetsBudgetException — carrying the count it needed — rather than building a mesh too large to draw. Two million by default.

string Name { get; set; }

The Mesh.Name of the result, for diagnostics. Null by default.

bool Smooth { get; set; }

Where a cell's vertex goes. True places it at the mean of the points where the field crosses the cell's edges, found by linear interpolation, which is what makes the surface smooth. False places it at the cell's centre, which is blocky and exactly reproducible by hand — for tests and for a deliberately voxel look.

Func<Vector3, Vector2> TexCoord { get; set; }

A texture coordinate for a point on the surface, called once per vertex. Null means the mesh has no texture coordinates and no tangents. When given, tangents are derived from the coordinates with Mesh.WithGeneratedTangents, so a normal map can sit on the result.

See also