mesh
Mojo module 🡭
mesh
A mesh of adjacent faces drawn as one shape: full coverage wherever two faces meet, anti-aliasing only at the outer silhouette.
Why a separate rasterizer. Two anti-aliased fills sharing an edge each blend their partial coverage of the edge pixels against the background rather than against each other, so a pixel both faces half-cover comes out half fill and half background. Measured on two same-colored triangles sharing a diagonal: 52 interior pixels off the fill color along a 60-pixel edge, the worst by 53 levels (#425). A surface plot has an edge between every pair of faces, so it renders with a light mesh drawn through it. No sequence of per-face fills can fix that, because the fix needs to know that the other face is there.
How this one works. Each face is rasterized hard-edged at
_SUBSAMPLE times the canvas resolution, in draw order, into a
scratch that starts fully transparent; a sub-sample’s centre belongs
to exactly one face under the top-left rule, so shared edges have no
gap and no double cover, and a later face covering a sub-sample simply
replaces or blends over the earlier one, which is the painter’s
algorithm a depth-sorted mesh relies on. Each output pixel is then the
premultiplied mean of its sub-samples composited over what the canvas
holds: opaque inside the mesh, a coverage fraction at the silhouette,
and untouched outside it. The silhouette gets _SUBSAMPLE-squared
coverage levels, the same as the sampled anti-aliased fills.
The scratch is a band’s worth of sub-sample rows, not the whole canvas, and the band body is the unit a batch or a supersampled region replays: a mesh records as one op holding a range into the batch’s side lists (#415), and each band rasterizes every face reaching its rows. Bands write disjoint rows, which is the whole safety argument.