Inside Plasma: Meshlet Edge Geometric Anti-Aliasing

Meshlet Edge Geometric Anti-Aliasing finds every geometric edge on screen, rebuilds the exact triangles that meet there and works out how much of each pixel they cover.

Edge detection used in MEGAA

In this Inside Plasma we open up a renderer feature we've been building: MEGAA, our new anti-aliasing technique. Our renderer already draws everything as meshlets, small clusters of triangles the GPU culls and draws on its own. MEGAA puts that data to a second use. It works out exactly which triangles meet at each edge on screen and smooths the edge from the real geometry. Before we get into how, here's the scene we built to break it.

Test scene of thin wires, bars, spheres, tori and cubes over a checkered floor, rendered with MEGAA at 1440p

Our stress scene at 1440p with MEGAA: Many thin wires, overlapping bars and curved silhouettes, the cases where aliasing is most visible.

Why another anti-aliasing technique

Most real-time anti-aliasing works on the finished image. Post-process filters look for sharp changes in colour and guess where an edge is and which way it runs. Temporal filters blend in pixels from earlier frames. Both are cheap, and both are guessing. A post filter can't tell a polygon edge from a sharp line painted in a texture, so it softens both. A temporal filter has to reject history when things move, so its edges change from frame to frame and thin details smear.

Multisampling (MSAA) doesn't guess: it stores several coverage samples per pixel while rendering. That costs memory and bandwidth on every render target, and it fits poorly with a modern frame where most lighting runs in compute.

MEGAA aims for the accuracy of multisampling at the cost of a single extra pass. The geometry is already on the GPU in meshlets, so instead of guessing where an edge is, we ask which triangle is in each pixel.

The idea in one frame

Our depth prepass already draws every visible meshlet. With MEGAA on, it also writes one 32-bit ID per pixel, made of the visible meshlet and the triangle within it. That ID lets the resolve pass go back to the mesh data, load the triangle's three vertices and project them to the screen. With exact triangles in hand, coverage is a geometry question: for each of eight sample positions inside the pixel, which triangle is closest and contains the sample?

Pipeline: the depth prepass writes depth and a triangle ID; classify finds edge pixels; the resolve rebuilds triangles and tests 8 samples; the final image only changes on edges

Step 1: knowing what is in every pixel

The ID is where the meshlets come in. A meshlet is a small cluster of up to 128 triangles that the GPU culls and draws as a unit. Because the ID names a meshlet and a triangle inside it, a single read takes the resolve from a pixel to that meshlet's vertex and index data.

Debug view where each meshlet is a different flat colour: a torus and a sphere broken into patches, with bars and a cube

The visibility IDs drawn as colours: every patch is one meshlet. The resolve can go from any pixel straight to the triangle that produced it.

Step 2: finding the edges

Most pixels sit inside one triangle and need nothing. The classify pass compares each pixel's ID, depth and normal with its neighbours and marks two kinds of edge:

  • Silhouettes, where one surface ends in front of another. These are the jagged edges people notice.
  • Creases, where two faces of the same object meet at an angle, like the corner of a cube.

A triangle boundary inside a smooth surface isn't an edge, even though the ID changes there, so the classifier leaves it alone. Only marked pixels go on to the resolve, and in a typical frame that is a small fraction of the screen.

Debug view on a dark background: green outlines around every silhouette, orange lines along cube and bar creases

Classified edges: green for silhouettes, orange for creases. Everything dark is skipped.

Step 3: meshlet edge topology

Rebuilding triangles only helps if the resolve can find all the triangles that touch a pixel. Some of them may not appear in any nearby ID: a wire half a pixel wide might lose every pixel centre to the surface behind it.

So when a mesh loads, we work out every triangle's three neighbours within its meshlet and store one 32-bit edge word per triangle. Each edge records the neighbouring triangle and a class: shared (a smooth join), seam (a hard crease or UV split) or open (the end of the surface). The resolve starts from the triangles it can see, then follows these links out two rings to pick up neighbours that are too thin to own a pixel. The classes also tell it when an ID change is just an internal smooth join it can skip.

Stress scene debug view with edges coloured by their topology class

The stress scene's edges as the resolve sees them using meshlet topology. Wires, bars and silhouettes are all found, including wires thinner than a pixel.

Step 4: the resolve

For each edge pixel, the resolve gathers the distinct triangles in a small window plus their neighbours from the edge words, projects them to the screen and tests eight sample positions against each one. The nearest triangle that contains a sample wins it. The pixel's final colour is a mix of its neighbours' colours, weighted by how many of the eight samples each surface won.

Because coverage comes from the triangles themselves, a wire too thin to reach any pixel centre still covers its share of samples and draws as a continuous line. Post-process filters can't recover detail that never reached a pixel.

MEGAA never touches pixels inside a surface. Over a seven-frame camera path in Sponza it changed about 71,000 pixels; a post-process filter changed over a million, most of them texture detail.

Results: the stress scene

Zoomed 5× without filtering, so every pixel shows. The reference is hardware MSAA with eight samples.

No AA SMAA MEGAA MSAA 8× reference
No anti-aliasing: thin wires break into dashes Post-process filter: wires softened but still broken MEGAA: continuous wires with smooth edges MSAA 8x reference
No anti-aliasing: crossing bars with stair-stepped edges Post-process filter on crossing bars MEGAA on crossing bars MSAA 8x reference on crossing bars

Look at the thin wires in the top row. Without anti-aliasing they break into dashes, and a post filter can only blur the dashes. MEGAA draws them unbroken, like the reference.

Error against MSAA 8x at 1440p: No AA 4.34, SMAA 1.88, MSAA 4x 1.75, MEGAA Lite 0.75, MEGAA 0.41

GPU cost in Sponza at 720p: SMAA 0.07 ms, TAA 0.08 ms, MEGAA Lite 0.20 ms, MEGAA 0.41 ms

MEGAA's error is less than a quarter of hardware MSAA 4×'s and about a fifth of SMAA's. The cost is higher too: today it runs several times slower than a post filter. The second half of this post covers where that time goes and the lighter variant we built to cut it.

Results: Sponza in motion

One frame from a scripted camera path, with the camera moving. Lighting effects that add frame-to-frame noise are off so only the anti-aliasing differs. Both crops come from where MEGAA changed the most pixels.

Sponza atrium frame with banners, columns and arches)

The full frame with MEGAA.

AA off SMAA TAA MEGAA MEGAA Lite
AA off: banner and column edges stair-stepped SMAA TAA, softer overall MEGAA MEGAA Lite
AA off: columns and banners SMAA TAA MEGAA MEGAA Lite

TAA smooths edges but softens the stonework and banner texture with them. MEGAA smooths the banner, column and arch outlines and leaves the texture exactly as rendered.

Where the time goes

The full path works in 8×8 tiles. Each tile collects up to 64 candidate triangles into shared memory once, then every edge pixel in the tile tests against that set. It gives the best quality, but tiles with a single edge pixel still pay for the whole setup.

MEGAA Lite drops the tiles. Classify writes edge pixels straight into a compact list, and each one resolves on its own from a 3×3 window plus one ring of topology neighbours. In Sponza it halves the total cost, from 0.41 to 0.20 ms. Its error against MSAA 8× is about twice the full path's, and still well under half of SMAA's or MSAA 4×'s.

About half of Lite's remaining cost isn't the anti-aliasing at all. It's the extra ID target the depth prepass now writes, which takes that pass from 0.17 to roughly 0.25 ms. That write is the next thing we're optimising.

Sponza, 720p AA pass Prepass ID write Total
SMAA 0.072 ms – 0.07 ms
TAA 0.082 ms – 0.08 ms
MEGAA 0.331 ms +0.076 ms 0.41 ms
MEGAA Lite 0.10 ms +0.10 ms 0.20 ms

Everything coming together in sponza

Limits and next steps

  • Geometry only. MEGAA fixes polygon edges. Shimmer from specular highlights, alpha-tested foliage and fine texture detail is left to other techniques, and it pairs with them.
  • Meshlet geometry only. Skinned meshes and anything drawn outside the meshlet path have no triangle IDs yet. Their edges get a cheaper depth-and-normal fallback.
  • Cost. Next up: a cheaper ID write in the prepass, and a better candidate set for Lite to close its quality gap with the full path.

Want to try Plasma? Register for the private beta.