# Anti-aliasing: diagnosis, survey and proposals (2026-10-27) Status: **research and diagnosis only.** Branch `aa-research` off main @d6daafca. There are no renderer changes on this branch. Scratch, drivers, raw shots and analysis scripts are in `logs/aa-research/` on nazrin: - `look.mjs` is the bench driver, a copy of the P2 round's; - `mkplan.mjs` writes the plans; - `img.ts`, `metrics.ts`, `still.ts`, `seqchg.ts`, `edgefrac.ts` and `owner.ts` are the analysis scripts; - `shots//` holds the raw PNGs and `timing.jsonl`; - `ref/` holds the 16-spp references; - `owner/` holds the sheets (§6). The owner's request: "Next up let's do something about the jagged edges on shadows and geometry. AA, presumably, but I'm a bit behind on SotA methods there." Evidence tags: - **[M]** measured this round on the RX 5700 (utsuho), 800×600 unless stated; - **[V]** measured by an earlier round; - **[C]** read from the code (file:line at main @d6daafca); - **[S]** from a cited source; - **[I]** inference or estimate. ## 0. Summary **There are two different kinds of jaggy, and one fix cannot cover both.** 1. **Geometry and far-detail jaggies are classic 1-sample aliasing.** - Cause [C]: one primary ray goes through each pixel centre, in both the world pass (`gbuffer-pass.ts:382-392`) and the entity pass (`entity-overlay-pass.ts:411-416`). - Where it shows: - silhouettes and creases; - colour/shading boundaries between voxels; - thin casters (the 1-voxel pole); - far content, where the LoD prune deliberately keeps cells as small as **0.5 px** (`tree-prune.ts:91-94` with `prunePixels` 2). - A 16-spp supersampled render removes it [M]. Measured: - **the 1-spp frame differs from the 16-spp reference by 5.5-8 levels (8-bit luminance) on edge pixels and by < 0.7 levels elsewhere;** - **in a slow pan (0.26 px a frame), 70-970 edge pixels a frame change by 24+ levels more than the reference does.** 2. **The shadow staircase is not screen aliasing. It is world-space quantisation per receiver voxel, and supersampling does not change it [M].** - Every receiver cell takes one shadow ray from its centre, and lighting is computed once per cell [C]: - `voxel-shadow-refresh-pass.ts:211-236`; - `voxel-shading-cache.ts:1241`; - `lighting-worklist-pass.ts:2213,4762`. - Each shadow edge is therefore a staircase of whole voxels (1/16 m, coarser in pruned regions). - On the 16-spp reference the staircase is pixel-for-pixel the same: only the 1-px steps *inside* each voxel step get smoothed (sheet `shadows-…`, rows 2-4). - The P2 filter is evaluated **per entry** (per receiver cell): `sun-shadow-filter.ts` pass 3, `filter_main`. - So its 2-voxel ramp is itself made of flat cells. - That is the "fuzzy staircase": a checkerboard of 2-3 grey levels along a diagonal edge (sheet row 2, columns 3-4). - The hypothesis in the brief is **confirmed**. - It also explains the sweep pop P2 reported: a cell flips whole. What the measurements say about each family: - **TAA would fix class 1 (including the motion shimmer) but not class 2.** A stable per-cell staircase is exactly what TAA converges to. - **MSAA-like extra visibility samples fit this renderer unusually well.** Shading is already decoupled from pixels: it is per voxel cell, deduplicated by the worklist. So an extra sample costs a primary ray plus a resolve tap, not extra lighting. - **Primary visibility costs 0.48-1.08 ms a frame for one sample per pixel** (gbuffer + entity overlay [M]). Brute 2×2 SSAA therefore costs about 2.1× the frame [M] and is out of budget. - **Adaptive sampling only on edge pixels is cheap in simple scenes and not cheap on foliage terrain** [M]: - depth/silhouette discontinuities are 1-2 % of pixels everywhere; - pixels with any colour step > 8 levels are 1-4 % in the fixtures and the house, but **10-17 % on a forested terrain view** (sub-pixel voxels: moiré contours on slopes, leaf edges). **Ranked proposals (§5):** | # | proposal | fixes | cost (800×600, RX 5700) | temporal? | |---|---|---|---|---| | **A** | **Per-pixel shadow reconstruction**: evaluate P2's V at each pixel's own position (not the cell face centre), plus sub-cell hard rays at boundary cells for small suns | shadow staircase, P2 banding, part of the sweep pop | +0.05-0.25 ms [I from P2's measured passes] | no | | **B** | **Adaptive visibility supersampling** (+ the LoD prefilter for sub-pixel texture): 4 rotated-grid rays only at detected discontinuities; resolve averages the cells' existing radiance | geometry and texture stair-steps, thin casters; most pan shimmer at edges | +0.1-0.35 ms [I] (fixtures, house); +0.5-0.9 ms on forested terrain if colour edges are resampled too | no | | **C** | **Light TAA** on top of B, history-validated by cell id + depth (NAADF-style), α = max(1/N, 1/12) | residual sub-pixel shimmer (far LoD, thin features), the sweep pop's last ~0.3-0.6 of contrast | +0.15-0.3 ms [I] | yes | | **D** | Spatial-only CMAA2/SMAA 1x | long-edge stair-steps only | +0.1-0.25 ms [S] | no; does not touch shimmer or shadows | **Recommendation:** 1. **Prototype A first.** It is the shadow complaint, and nothing else fixes it. 2. **Then decide the geometry route on terrain evidence.** - In the fixtures and the house, B (history-free) is cheap and sufficient. - On forested terrain the main class is sub-pixel voxel shimmer (G4: 10-19 % of pixels carry colour edges). There B costs 0.5-0.9 ms. The cheaper candidates are: - the **LoD prefilter** (`prunePixels` 2 → 4: no cell below a pixel; history-free; a blockier far field); - **C** (TAA, ~0.15-0.3 ms, temporal). - The prototype round should measure B silhouettes-only + prefilter against C on the terrain poses, and give the owner the look and the numbers. 3. **The serious "no temporal" option is A + B (silhouettes) + the LoD prefilter.** The evidence allows it: - the renderer is not noisy when still (0 px changing > 2 levels between still frames on every celestial pose; ≤ 6 levels on terrain [M]); - every jaggy class is deterministic. It leaves sub-pixel *silhouettes* (thin far features) and the far-field look as the trade-off. Owner decisions are in §7. ## 1. How the frame is built (what "AA" can hook into) [C] - **Primary visibility, one ray per pixel centre:** - `gbuffer-pass.ts:382-392` `pixelRd` (`p + 0.5`) walks the pruned SVT. Tile packets bound the ray set with `tileEdgeRd` (`:394`, `:446-449`), so a jitter or extra samples must widen the packet planes by the jitter. - Entities trace the same way in `entity-overlay-pass.ts:411-416,466`. Lighting picks the nearer of world and entity hit per pixel. - **The hit's identity is a voxel shading cache (VSC) slot.** The cell is the voxel, or the region's LoD cell: `snapBits` = the region's `ml` (`gbuffer-pass.ts:637`, `vscComputeCellCenter` `voxel-shading-cache.ts:1241-1245`, `cellSize = 4^ml`). - **Lighting runs once per visible-surface entry** (one per distinct cell seen this frame) in `lighting-worklist-pass.ts:2213` `surface_main`: - the cached sun transmittance of the cell; - entity casters traced inline from the cell's shadow origin (`:2495-2520`); - surface GI per cell; - albedo per cell. - **The resolve runs per pixel** (`:4730` `resolve_main`). It reads its entry's radiance (`:4762`), then adds fog, transparency and the glass glint (`glassSurfaceTerm`, `:3292`, the only specular term) and applies ACES. It writes `rgba8unorm`, which `blit-pass.ts` copies 1:1 to the swap chain. There is **no upscale**: render resolution = canvas size. - **Sun shadow** [C]: - **Terrain casters:** one ray per cell, toward the light's centre, from the cell centre pushed out of the cell (`voxel-shadow-refresh-pass.ts:211-236` `traceCentre` / `refreshShadowOrigin`). - **Entity casters:** the same ray, traced inline per entry. - **P2 filter** (`sun-shadow-filter.ts`): - per pixel: a source sample carrying its cell's hard value (`samples_main`, `:230`); - per entry: a gather around the **cell's face centre** (`filter_main`, `:395`, `p = rec.xyz`), which moves the entry's radiance by `contrib·(V − hard)`. - **No history anywhere for colour.** GI keeps per-cell world-space history. The P2 filter is history-free. - **The debug HUD** is drawn after lighting by `debug-ui-pass.ts`, one render pass after the overlays. Any temporal pass has to run before it. Consequence: this renderer already has **decoupled, object-space shading at voxel-cell rate**, the texel-shading architecture [S: Hillesland & Yang 2016]. A pixel's colour is "which cell do I see" plus per-pixel fog and transparency. Aliasing therefore lives almost entirely in the *visibility* (which cell) and in *cell quantisation* (what the cell holds), not in shading noise. ## 2. Diagnosis on the real renderer [M] ### 2.1 Method - **Fixtures:** - `celestial-sweep` (the P2 round's caster set); - `play-day` (the house, allays, grass); - a generated terrain world (`WORLD=aa-terrain`; far LoD). - **Capture conditions:** - the player at the camera (the server ships full detail around the player, as the P2 round found); - each pose waits for `wait_settled` and the LoD ladder (`scripts/lod-settle.mjs`); - sun 0.53°, still (time 0, rate 0) unless stated; - the P2 filter on (production) unless stated. - **Reference:** the same session plan on a page booted at `?res=3200x2400` with `prunePixels` 8. - `prunePixels` 8 keeps exactly the LoD the 800×600 view has at the default 2: `viewMinLevel` depends on `prunePixels / renderH` only. - Each 3200×2400 shot is box-filtered 4×4 down to 800×600: **16 samples per pixel**, averaged after tonemapping, as an MSAA resolve after ACES would be. - The scene content is therefore identical, and only sampling differs. - **Metrics** (`metrics.ts`): - edge pixels are where the reference's Sobel magnitude exceeds 6 levels; - error is |ΔY| on 8-bit luminance; - a "jaggy px" is an edge pixel more than 24 levels off. - **Temporal metrics:** - **Pans:** the camera yaws by 0.0006 rad a frame (≈ 0.26 px at the centre) for 16 frames at 1× and 6 at 16 spp. Per frame pair, the 1× frame-to-frame change is compared with the reference's change for the same camera step. The excess is crawl/shimmer, because the reference's change is the true image motion. - **Still sequences:** 8 frames with nothing touched. - **Moving sun:** the stepped clock (0.02° a frame), reset afterwards. ### 2.2 The classes | # | class | source (file:line) | static / temporal | visible how much [M] | does 16 spp fix it? | |---|---|---|---|---|---| | G1 | **Silhouettes and creases, near and mid** (box tops, plate rims, the house, entity outlines) | one ray at the pixel centre: `gbuffer-pass.ts:382-392`, `entity-overlay-pass.ts:411-416` | both: static stairs; edges crawl in pans | edge error 5.5-8.0 levels against 0.06-0.64 off-edge; 385-1 682 jaggy px a frame (celestial poses, P2 column) | **yes** | | G2 | **Thin geometry** (the 1-voxel pole, the antenna, slats seen edge-on) | same; features ~1 px wide | mostly temporal: the pole's width pulses 1↔2 px in a pan | pole pose: 762 px a frame of pan excess > 24 levels (the worst celestial pose) | **yes** | | G3 | **Voxel-cell colour/shading boundaries inside a surface** (two lit voxels with different GI, a material change, the ml-region seam) | per-cell lighting (`lighting-worklist-pass.ts:2213`) read per pixel (`:4762`): a hard step at every cell edge, sampled at 1 spp | static stairs where cells ≥ 1 px; shimmer where cells < 1 px | the same edge statistic; dominant on far terrain (§2.4) | **yes** (the step itself is the intended voxel look; its *pixel* stairs are aliasing) | | G4 | **Far LoD cells smaller than a pixel** | `prunePixels` 2 (`settings.ts:668`) → `tree-prune.ts:91-94` keeps a level until its cells are **0.5 px**; each band holds 0.5-2 px cells | temporal: sparkle/crawl in motion; LoD band pops are a separate event | §2.4 | mostly (sub-pixel cells average out); band pops no | | S1 | **Shadow staircase on near receivers** | one shadow ray per receiver cell: `voxel-shadow-refresh-pass.ts:211-236`; entity casters per entry, `lighting-worklist-pass.ts:2495-2520`; cells snapped to `ml` (`gbuffer-pass.ts:637`) | static, world-locked (does not crawl in a pan); pops when the sun moves | sheet rows 2-4: steps of 10-16 px on a box face and on the floor at the avatar's feet | **no**: identical stairs at 16 spp | | S2 | **P2's banded ramp ("fuzzy staircase")** | the filter's V is per entry, around the cell's face centre (`sun-shadow-filter.ts:395-415`, `p = rec.xyz`) | static | sheet row 2, P2 columns: a 2-3-level checkerboard along the diagonal | **no** | | S3 | **Shadow edges on far receivers** (cells ≈ 1 px) | S1 at small cell size | static stairs + crawl | sheet row 1: 1-px stairs | **yes** (cells ≈ pixels, so it is ordinary aliasing there) | | S4 | **Sweep pop** (sun moving) | a cell's one ray flips whole (P2 doc §6) | temporal | 1 461 px a frame change > 10 levels at 1×, 673 at 16 spp; > 20 levels 389 → 269 | partly: 16 spp removes the far-floor part (cells ≈ px), not the near cells | | T1 | **Noise when still** (GI speckle, sampling noise) | — | — | **none**: 0 px a frame change > 2 levels on every terrain-only pose (celestial: overview, highedge, pole, lowplate, thin, glass); ≤ 6 levels on the terrain world | n/a | | T2 | **Specular** | `glassSurfaceTerm` (`lighting-worklist-pass.ts:3292`) only; per-pixel, smooth Fresnel, normals per voxel | — | not seen on the glass pose; edge error 4.2 | n/a | Notes on the table: - The `slats` pose and the `play-day` poses do change when still. In `slats` it is the first-person body's GI settling after the camera move (bottom of the frame). In `play-day` the allays move. Neither is a renderer noise source. - T1 matters for the choice of method. **Nothing in this renderer needs temporal *denoising*.** A temporal method would be there only for anti-aliasing. ### 2.3 Numbers per pose [M] `celestial-sweep`, P2 on, 1× against 16 spp (`metrics.ts`, `logs/aa-research/metrics-*.txt`): | pose | edge px | edge err | off-edge err | jaggy px | pan: edge excess | pan: px/frame excess > 24 | pan change 1× / ref | |---|---|---|---|---|---|---|---| | overview | 2.2 % | 6.6 | 0.06 | 710 | 3.8 | 417 | 0.072 / 0.048 | | highedge (box + plate shadow) | 2.3 % | 5.5 | 0.64 | 449 | 2.6 | 150 | 0.080 / 0.054 | | pole | 1.8 % | 7.0 | 0.08 | 861 | 5.1 | 762 | 0.067 / 0.065 | | slats | 4.2 % | 8.0 | (body) | 1 682 | 5.0 | 969 | — | | lowplate | 1.3 % | 6.7 | 5.3* | 385 | 1.9 | 67 | 0.021 / 0.015 | | thin rail | 1.1 % | 3.7 | 0.01 | 18 | 2.2 | 92 | 0.021 / 0.014 | | glass | 1.0 % | 4.2 | 0.07 | 95 | 2.6 | 116 | 0.028 / 0.025 | \* With hard shadows the same pose has 1.06: the P2 filter's output depends on render resolution. Its window and stride are in pixels, so the 16-spp page filters slightly differently. That is not an aliasing measure. - With hard shadows (filter off) the edge errors are within ±1 level of these. The jaggy counts are 509-894. Geometry AA is indifferent to P2. - **Share of pixels an adaptive sampler would touch** (`edgefrac.ts`: a pixel whose 4-neighbour luminance step exceeds 8 levels): | scene | poses | share | |---|---|---| | celestial | — | 1.1-2.9 % | | play-day | inside, sweep (house), high | 2.3-3.3 % | | play-day | street (sky, grass, one allay) | 0.45 % | | terrain | — | §2.4 | ### 2.4 Far terrain and LoD (G4) Generated world (`WORLD=aa-terrain`, earthlike, seed 42691; forest and snow). Two poses near spawn: - hiA: 35 m up, looking down over forest; - hiB: 21 m up, looking along the ground. Sheet `owner/terrain-current-vs-16spp.png`. Columns: 1 spp, 16 spp, vt 10. **Caveats (two confounds) [M]:** - **The sun follows the world clock.** It moved between sessions, so whole-frame error numbers are dominated by shadow motion and are **not used**. Compare crops. - **The LoD state differs between sessions in a world still streaming.** - The first 1× session settled with coarse mid-range blocks (`shots/ter1-unsettled/`). - Even the re-run differs from the reference at mid range. - This is the HANDOFF's measurement hazard, and the reason `lod-settle` alone does not make a generated world comparable. What the crops show: 1. **Snow slope** (cells 0.5-1 px). - At 1 spp the terrace steps of the voxel slope read as **moiré**: broad false diagonal bands and broken rings. - At 16 spp they are the true fine, regular contour lines. - vt 10 shows the voxel cells are sub-pixel. - This is **G4 + G3**: per-voxel shading on cells smaller than a pixel, point-sampled. 2. **Mid-distance trees.** Silhouette stairs (G1) and blocky leaf cells at 1 spp; clean at 16 spp. 3. **A near tree's crown** (cells 2-4 px). Mild: the cell pattern is the voxel look and survives at 16 spp; only its edges soften. 4. **Grass with tree shadows.** - 1 spp: moiré in the grass shading, and stair-stepped shadow outlines. - 16 spp: the grass is uniform. - The shadow outlines follow cells (S1, at ~1-2 px cells, so mostly fixed by supersampling here). **Numbers [M]:** - **Edge share:** pixels with a 4-neighbour colour step > 8 levels are **10-19 %** of the frame. Depth discontinuities (vt 30) are only 1.6-1.8 %. The rest is voxel texture: G3/G4. - **Pan shimmer** (the first 1× session, hiB, 0.26 px a frame; no reference pans: the 16-spp page lost its connection during the terrain pan, a 3200×2400 limit): - 1 098 px a frame change by > 40 levels, and 3 902 by > 10; - the celestial poses had 42-349 px a frame by > 40. - **Still:** ≤ 6 levels. - **GPU:** 5.4 ms at hiA, with the gbuffer at 0.85 ms (a forest is expensive to trace). **Conclusion.** On real terrain the dominant aliasing is **G4, sub-pixel voxel texture shimmering in motion**, not silhouettes. Proposal B handles it only if it resamples 10-19 % of pixels (≈ 0.5-0.9 ms). Cheaper candidates are the LoD prefilter (`prunePixels` 4: no cell below 1 px) or C (TAA). ### 2.5 Shadows: why supersampling cannot fix them Sheet `owner/shadows-hard-p2-current-vs-16spp.png`. Columns: hard 1×, hard 16 spp, P2 1×, P2 16 spp, P2 at a 4° sun, vt 46 (sun transmittance, white lit). Rows: 1. **Far floor, the high plate's edge** (cells ≈ 1-2 px). - The hard edge is a 1-px staircase. At 16 spp it becomes a clean straight line, because here the cell is about a pixel. - P2 turns the edge into two parallel stripes, each a row of flat cells. That banding is "fuzzy". 2. **The same shadow on the receiver box's face** (cells ≈ 12-16 px). - The hard staircase is identical at 16 spp; only each step's 1-px edges soften. - P2 at 1× and 16 spp is the same **checkerboard of flat cells** in 2-3 grey levels. At 4° it widens and keeps the checkerboard. - This is the owner's "fuzzy staircase". 3. **The avatar's shadow at its feet** (an entity caster, near receivers). - A zig-zag of whole floor voxels, the same at 16 spp. - At 0.53° P2 changes nothing (contact, radius ≈ 0). At 4° it gives a diamond lattice of grey cells. 4. **The 1-voxel pole's shadow on the floor.** - The true shadow of an axis-aligned pole is a straight strip. Rendered, it is a chain of whole receiver voxels, the same at 16 spp. - P2 at 4° turns it into a lattice of grey cells. 5. **The thin rail** (2×2 voxels, 200 up). Fine cells: 16 spp straightens it. P2 doubles its edge into stripes (two cell rows). **The mechanism, in one sentence:** a receiver cell's shadow is one number, so a shadow boundary can only fall on cell boundaries. - Near the camera a cell spans many pixels, so the boundary is a staircase of world-space voxel steps. - Any screen-space AA (MSAA, SSAA, TAA, SMAA) sees that staircase as *real geometry* and preserves it. - A shadow fix has to put the boundary **between** cell centres, at sub-cell positions. That is the texel-shading literature's answer to shading-rate quantisation: filter the shading term across neighbouring cells at the sample's in-face position, as bilinear texel shading does [S: Hillesland & Yang 2016]. - **What the true edge looks like:** a straight axis-aligned caster edge casts a straight line on a flat receiver. A voxelised diagonal caster casts the caster's *own* staircase, at the caster's voxel scale, stretched by projection. That staircase is geometry and should stay. **The sweep pop** (`owner/sun-move-current-vs-16spp.png`, five frames of a sun moving 0.02° a frame; rows 1× and 16 spp): - The near box face flips whole cells in both rows. - The far floor flickers at 1× and less at 16 spp. - Pixels a frame changing by > 20 levels: 389 at 1×, 269 at 16 spp [M]. Supersampling removes the far-floor share only. ### 2.6 Play-day Sheet `owner/playday-current-vs-16spp.png`. Columns: hard 1×, hard 16 spp, P2 1×, P2 16 spp, vt 10 (voxel-id hash at 1×). The play-day sun follows the fixture's clock, so the sun patch sits slightly differently in the two sessions; compare shapes, not positions. Rows: 1. **Indoor sun patch on the floor** (cells ≈ 4-6 px). - The staircase is whole floor voxels, and identical at 16 spp. - P2 adds a banded fringe one cell wide. - vt 10 shows the cells the steps follow. 2. **Window frame** (geometry). 1-px stairs at 1×, clean at 16 spp. 3. **The house's corner and door** (geometry). The same. 4. **The roof antenna** (1 voxel wide, ~1 px at this distance). - At 1 spp it **breaks into pieces and loses its top**, because the centre rays miss it. - At 16 spp it is a continuous thin line. - This is G2 at its worst. A static frame does not show it as "jagged" so much as **wrong**. 5. **An allay's shadow on the grass.** P2 at 1× gives a lattice of grey cells. The allays move, so the reference has none at that spot. Numbers (`logs/aa-research/metrics-play.txt`) [M]: | pose | edge px | edge err | off-edge err | jaggy px | pan: px/frame excess > 24 | |---|---|---|---|---|---| | inside | 1.8 % | 6.4 | 0.36 | 359 | 744 | | sweep (house) | 2.6 % | 8.7 | 1.25 | 1 154 | 2 133* | | high (house + antenna) | 2.3 % | 9.4 | 1.28 | 1 233 | 1 013* | \* Includes moving allays, which change between sessions. The `street` pose (one allay against the sky) is dominated by the allay's motion and is not used. Timing at the play-day poses: GPU 2.7-4.0 ms. Primary visibility (gbuffer + entity overlay) 0.86-1.08 ms. The entity overlay alone is 0.38-0.55 ms here, because allays are many entities. ## 3. State of the art, mapped onto this renderer Sources are tagged **[P]** for primary (paper, official slides/docs, official code) and **[2°]** for secondary (blog, press, forum). "Not found" means searched and not verified. ### 3.1 TAA and TAAU **Mechanism.** Jitter the sample position each frame with a sub-pixel Halton(2,3) sequence: - 8 samples in UE4 and Bevy; - 16 in INSIDE; - 32 in three.js TRAA. Then: - reproject last frame's output with motion vectors; - rectify it against the current neighbourhood; - blend with an exponential weight α. **Foundations:** - Karis, "High Quality Temporal Supersampling", SIGGRAPH 2014 Advances [P] (https://advances.realtimerendering.com/s2014/index.html). Contributes: - closest-depth motion vectors; - clipping in YCoCg; - blending in a reversible tonemapped space; - lowering α near clamping. - Salvi, "An Excursion in Temporal Supersampling", GDC 2016 [P] (https://developer.download.nvidia.com/gameworks/events/GDC2016/msalvi_temporal_supersampling.pdf). Contributes: - **variance clipping**: an AABB from mean ± γσ of the 3×3, with γ ≈ 1; - the explicit warning that variance clipping *flickers when the input is strongly aliased*: thin features that come and go with the jitter collapse the variance and clip history. His fix is "take care of it by using other anti-aliasing methods". - Pedersen, INSIDE (GDC 2016) [P] (https://github.com/playdeadgames/temporal, MIT): - a luminance-difference feedback weight of 0.88-0.97; - 3×3 dilation; - **motion blur that rises with velocity to hide ghosting**, a velocity-dependent mode. **The survey.** Yang, Liu & Salvi, "A Survey of Temporal Antialiasing Techniques", EG STAR 2020 [P] (http://behindthepixels.io/assets/files/TemporalAA.pdf). - **Taxonomy:** jitter / reprojection / accumulation; history *rejection* (depth, normal, id) against *rectification* (clamp, clip, variance clip); TAAU; challenges. - **Accumulation maths.** With a fixed α = 0.1, effective samples are: | frames | effective spp | |---|---| | 5 | ≈ 2.2 | | 10 | ≈ 5.1 | | 15 | ≈ 9.8 | | ceiling | 19 | - Equal weights are optimal: store a per-pixel count N and use α = 1/N. - With α = max(1/N, 1/12), the owner's bar ("plausible frame 1, right by ~3, good by ~12") is met by construction. - **Failure modes:** - *blur*, both from resampling (fixed by Catmull-Rom history) and from rectification eating sub-pixel lines; - *ghosting* and lag; - *temporal instability* on moiré or strongly aliased input. "Avoiding ghosting and flickering are often contradicting goals." - *undersampling at disocclusion*, fixed by spatial AA or adaptive rays there. - **Cost:** UE4 TAA on an RTX 2080 Ti is 0.14 / 0.24 / 0.52 ms at 1080p / 1440p / 4K. **FSR 2 / 3** (AMD, MIT) [P] (https://github.com/GPUOpen-Effects/FidelityFX-FSR2; https://gpuopen.com/manuals/fidelityfx_sdk/techniques/super-resolution-upscaler/). - Passes, in order: 1. a luminance pyramid; 2. reconstruct-and-dilate: closest depth, and forward-reprojected *previous depth* via 32-bit atomics; 3. depth clip (disocclusion); 4. **locks** for thin features, which skip rectification there (FSR 3.1 replaces locks with luma-instability and shading-change passes); 5. Lanczos-2 reproject-accumulate with a YCoCg clamp; 6. **reactive** and **transparency/composition** masks; 7. RCAS sharpening. - For ray tracers: "the sub-pixel jitter should be applied to the ray's origin". Never emit a (0,0) jitter. - **Cost on the RX 5700 XT (our GPU's bigger sibling)** at 1080p output: 0.6 ms (Quality) and 0.5 ms (Performance) upscaling. No native-AA number is published. - **No WGSL port found.** Porting is possible but not drop-in: texture atomics would become buffer atomics; f16 and subgroups are optional WebGPU features whose Safari support was not verified. **UE5 TSR** (Epic docs) [P] (https://dev.epicgames.com/documentation/en-us/unreal-engine/temporal-super-resolution-in-unreal-engine). - Ideas: - history kept at up to 200 % of display resolution; - parallax disocclusion; - shading rejection; - **flicker analysis, disabled per pixel for moving objects** (a moving/static rule our parity rule forbids); - an FXAA-like spatial AA on rejected pixels; - history "resurrection". - Epic's own limit: TSR cannot recover a 1-px feature moving half a pixel a frame once reprojection blur has eaten it. - Cost: about 1.1-1.5 ms on PS5 for Fortnite. - An Abadie talk with more detail: not found. **DLAA, as the outcome bar** [P] (DLSS Programming Guide): a learned temporal reconstruction at native resolution, widely judged the best-looking TAA-class result [2°]. Its cost is 0.6-1.5 ms at 1080p on tensor-core GPUs. Not an option here: vendor SDK, no WGSL. **WebGPU reference code** [P]: - **Bevy's TAA** (WGSL/WESL, `bevy_anti_alias/src/taa/taa.wesl`): - Karis + Salvi; - 5-tap Catmull-Rom history, closest depth of 5 taps; - YCoCg variance clip, γ = 1; - α = clamp(1/confidence, 0.015, 0.1). - **Confidence grows only while motion < 0.01 px and resets otherwise.** That is precisely the "sharpens only when still" mode shift the owner forbids. - **three.js** `TRAANode`, `TAAUNode`, `FXAANode`, `SMAANode`, `FSR1Node`, `SharpenNode` (TSL → WGSL). TRAA's γ is also motion-dependent. - Bevy also ships SMAA, FXAA and AMD RCAS in WGSL. ### 3.2 Spatial / morphological AA | method | source | idea | cost [S] | |---|---|---|---| | MLAA | Reshetov, HPG 2009 [P] | find L/Z/U shapes in edges, blend by area | — | | DLAA (Andreev, 2010) | SIGGRAPH 2011 AA course [P] (https://www.iryoku.com/aacourse/) | blur along the edge direction | — | | FXAA 3.11 | Lottes [P] | local contrast, short edge search, one pass | 0.39 ms on a GTX 560 at 1080p | | SMAA 1x / T2x / S2x | Jimenez et al., EG 2012 [P] (https://github.com/iryoku/smaa) | 3 passes, diagonals, corners; T2x adds a 2-frame jittered reprojection | 1x 1.02 ms, T2x 1.32 ms (GTX 470, 1080p) | | CMAA2 | Intel 2018, compute [P] (https://github.com/GameTechDev/CMAA2) | conservative Z-shapes | **0.10 ms (Vega 64, 1080p)**, 0.24 ms at 4K; SMAA 0.23 / 0.80 | - **Common weakness** (SMAA paper, survey): no sub-pixel reconstruction, so thin and distant features shimmer frame to frame. That is G2 and G4 here, and exactly the motion case the owner sees. - **For us** they would straighten long stair-steps (G1, S3). They cannot help S1/S2: a world-space staircase of 16-px steps is "real" to them, and they would blunt the corners of the voxel look itself. - Our input has few edge pixels in simple scenes (1-4 %), which is MLAA's best case. Forested terrain reaches 10-17 %, mostly sub-pixel voxel texture, where MLAA does nothing useful. ### 3.3 Analytic, coverage and adaptive AA for traced geometry - **Ray differentials** (Igehy 1999) [P] and **cone tracing** (Amanatides 1984) [P] give each ray a footprint. Inigo Quilez applies them to band-limit procedural shading in ray marchers [P] (https://iquilezles.org/articles/filteringrm/). - In our tracer the hit cell's bounds are exact (`hit.cellMin/Max`, `gbuffer-pass.ts:569-575`). Each pixel could compute the *coverage* of its footprint by the hit face analytically. That is GBAA-like geometric AA: blend with the neighbour across the face edge. - It handles edges with ≥ 1 px of each surface. It cannot invent the far side of an edge whose other surface is sub-pixel, and it cannot see thin features the centre ray missed. - **No published voxel-DDA analytic edge AA found.** - **Adaptive supersampling.** - Whitted 1980 [P]; Holländer et al., "Adaptive Supersampling for Deferred AA", JCGT 2013 [P]: near-SSAA results while halving shading samples. - **NVIDIA Adaptive Temporal Antialiasing** (Marrs et al., HPG 2018) [P] (https://research.nvidia.com/sites/default/files/pubs/2018-08_Adaptive-Temporal-Antialiasing/adaptive-temporal-antialiasing-preprint.pdf): - TAA everywhere; - a per-pixel mask (temporal luma change + depth Sobel) sends **~5-6 % of pixels** to 8×/4×/2× ray-traced supersampling (n-rooks, no jitter); - disocclusions go to FXAA; - the RT mask is *sticky* for a few frames "to reduce flicker from rapid shifts". - Result: 8× on 6 % of pixels for < 0.5 rays a pixel. - Their stated rule: quality must match across regions, or the region boundaries flicker. - In our renderer **extra primary rays are cheap relative to shading.** Shading is per cell and already deduplicated, and the DDA gives exact cell ids for a better discontinuity mask than a depth Sobel. ### 3.4 Shipped voxel / ray-marched work - **Teardown.** Per Wittens' RenderDoc teardown [2°] (https://acko.net/blog/teardown-frame-teardown/): - per-object 3D-texture DDA; - the final pass is TAA with a jittered view, which is the fourth temporal reprojection in the frame; - blue-noise screen-door transparency confuses the TAA and ghosts. - Statements by Gustafsson himself on TAA: not found. - **NAADF** (TU Wien, CGF 2026) [P] (https://www.cg.tuwien.ac.at/research/publications/2026/ulschmid-2026-naadf/), the closest academic analogue. - "Due to the discrete, grid-like structure of voxel worlds, aliasing occurs more often, particularly in the distance and at edges between voxels." - It keeps 32 frames of per-pixel samples and **rejects by depth range and a material/path hash, not by colour clamping**. - Its claim: colour-clamped TAA blurs and ghosts even on noise-free voxel albedo. - Cost at 1440p on an RTX 3090 Ti: 0.16 ms for its TAA baseline, 0.84-1.42 ms for the 16/32-sample method (0.5-1 GB). - **gvox_engine** (Gabe Rundlett) [P]: vendors kajiya's TAA plus FSR2. - **Octo** (Douglas Dwyer, Rust/WebGPU voxel ray marcher) [P]: AA method not stated. - **Minecraft RTX** uses DLSS [2°]. - AA details for Java shader packs (SEUS, BSL, Complementary), John Lin, Atomontage, Voxel Quest, Ethan Gore and Lay of the Land: not found. - **Takeaway:** the shipped voxel ray tracers that say anything use TAA, and the one paper that measures it on voxels found colour-clamp TAA blurs voxel albedo. None used adaptive extra rays (not found). ### 3.5 Shadow-specific - **Texel / object-space shading** (Hillesland & Yang, AMD, EG 2016) [P] (https://gpuopen.com/learn/texel-shading/): - shades texels in an atlas, then **bilinearly filters the shades** at each pixel's texture coordinate. That is how object-space pipelines hide shading-rate quantisation. - Costs 0.55-0.86 ms on an R9 290X at 1080p. - Its blog warns that bilinear alone "is not necessarily good enough for a final shade". - Our VSC is the same structure at voxel rate, without the filter at lookup. **P2 is in effect a screen-space PCF whose output is again stored per texel.** - **Shadow denoisers:** - AMD FidelityFX Shadow Denoiser [P]: tile classification, 1 ray a pixel, temporal plus à-trous; - NVIDIA SIGMA [P]: about 0.4-0.6 ms at 1080-1440p; - SVGF [P]. - All of them assume per-pixel shadow rays; ours are per cell. - **Shadows under TAA.** ATAA notes that shadows do not move with the receiver's motion vectors [P]. A per-cell hard shadow is world-locked and stable under jitter, so TAA would keep its staircase perfectly. ## 4. Method-by-method fit Cost is at 800×600 on the RX 5700. For scale [M]: | item | cost | |---|---| | primary visibility for 1 spp (gbuffer + entity overlay) | 0.48-1.08 ms (celestial overview 0.68, highedge 0.53; play-day street 0.86, high 1.08) | | worklist | 0.11-0.27 ms | | resolve | 0.09-0.12 ms | | whole frame | 2.3-4.1 ms | | same frame at 1600×1200 (highedge, LoD held) | 4.81 ms (2.1×) | | same frame at 3200×2400 (overview) | 27.2 ms (6.6×) | | method | cost (ms) | fixes | motion behaviour vs the bar | rule conflicts | Safari / WGSL | |---|---|---|---|---|---| | Brute SSAA 2×2 | +2.5 to +4.4 [M] | G1-G4, S3 | perfect, history-free | none | trivial, but out of budget | | **Adaptive visibility samples (B)**: 3 extra rays at edge pixels, resolve averages cell radiance | +0.1-0.35 [I] (edge px 1-4 % × 3 rays × ~2-3× incoherence + mask + compaction); +0.5-0.9 on forested terrain (10-17 % colour edges) [I] | G1, G2 (where detected), G3, S3 | history-free: identical still or moving | must trace entities too (parity: the entity overlay takes the same samples) | plain compute; no optional features | | Analytic coverage (GBAA from the DDA cell bounds) | +0.05-0.1 [I] | G1 at ≥ 1-px edges | history-free | none | plain compute | | CMAA2 / SMAA 1x | +0.1-0.25 [S, scaled] | G1, S3 (long edges) | history-free, but shimmer stays (G2, G4) | may soften the voxel corners | Bevy/three.js WGSL exist (SMAA, FXAA); CMAA2 port needed | | FXAA | +0.05-0.1 [S] | G1 partly | shimmer stays; blurs voxel albedo | soft look everywhere | WGSL exists | | **TAA (C)**, NAADF-style rejection, α = max(1/N, 1/12) | +0.15-0.3 [I; S: UE4 0.14 ms at 1080p on a 2080 Ti] + motion vectors | G1-G4, the last of S4 | frame 1 = the 1-spp image (plausible); ~3 frames ≈ 2× spp; 12 frames ≈ 8-10 spp | **mode-shift risk**: any TAA is sharper still than moving (history weight is capped by reprojection blur); Bevy's/three.js's still-only confidence must not be copied. Entities need prev-pose motion vectors (parity: the parts table gets a previous pose for every part). HUD after TAA. P2 and the resolve before it. Glass and visual-card overlays need a reactive mask. | plain compute + one RGBA16F history; the jitter goes on the CPU-side camera basis | | FSR2-class TAAU | +0.5-0.6 at 1080p output [S: RX 5700 XT] | as TAA, plus upscale headroom | as TAA | as TAA, plus locks/reactive heuristics to tune | **no WGSL port**; texture atomics → buffer atomics; f16/subgroups optional | | **Per-pixel shadow reconstruction (A)** | +0.05-0.25 [I] | S1 (where the penumbra radius > 0), S2, part of S4 | history-free | none: entities and terrain take the same rule, as P2 does | plain compute | | Sub-cell hard rays at boundary cells | +0.02-0.1 [I] (boundary cells are P2's mixed-tile share, 2-11 % of entries [V], × 4-16 rays) | S1 at contact and small suns | history-free | none | plain compute | | LoD prefilter (`prunePixels` 2 → 4: no cell below 1 px) | **saves** nodes and traversal | G4 | history-free | coarser far look (owner taste) | n/a | ## 5. Proposals ### A. Per-pixel shadow reconstruction (rank 1: the owner's shadow complaint) **What.** Keep one hard ray per cell, and P2's per-pixel samples and tile classification. Then: - Evaluate V **at each pixel's own hit point**, not at the cell's face centre, for pixels in mixed tiles. - The gather's centre `q0` and the receiver plane already come from the pixel in `samples_main`. - The per-entry pass becomes per-pixel over the mixed tiles' pixels only. - The resolve applies `contrib·(V_pixel − hard)` per pixel. The record already carries `contrib`. - Stage A2, for small suns and contact, where P2's radius is ~0: at **boundary cells only** (a cell whose 6 face neighbours disagree on the hard value), trace a 4×4 grid of sub-cell hard rays on the visible face. Store a 16-bit mask in the slot's spare state (or a side table). The pixel reads its sub-cell. This places the hard edge to 1/4 voxel, i.e. 1/64 m. **Look [I].** - A straight caster edge gives a straight ramp, P2-wide (≤ 2 voxels), with no checkerboard. - At 0.53° with A2, the edge looks hard and straight to 1/4 voxel. - Contact stays sharp, as the height rule makes it. **Cost [I from §4 of the P2 doc].** - P2's per-entry filter costs 0.08-0.15 ms for its 3-11 % of entries. - Per pixel, the gather centres multiply by pixels per entry in mixed tiles. Near the camera that is up to ~100, but the window stride is per voxel, so a centre's work is bounded the same way. - Estimate +0.05-0.25 ms, plus A2's rays: boundary cells × 16. They are traced in the refresh only when the cell is re-traced (the sweep), so a still sun pays nothing. **Motion.** - History-free. Nothing knows whether the sun or a body moves. - The sweep pop shrinks: the hard edge moves in 1/4-voxel steps (A2), and V varies continuously in x. **Risks.** - A pixel-rate filter in a close-up is the P2 doc's first form (0.65-1.75 ms) unless the stride per voxel is kept. - A2 needs a face-plane parameterisation per slot (dominant normal axis). **Prototype plan.** 1. A1 behind a `set_debug` flag, timed at the P2 poses. Sheet: the shadow rows above. 2. A2 on boundary cells. 3. The surface-GI gate's GPU lane (lighting change). ### B. Adaptive visibility supersampling, shared shading, with the LoD prefilter (rank 2: geometry) **What.** 1. After the 1-spp gbuffer and entity overlay, a mask pass flags a pixel when either: - its 3×3 holds a different **cell id** or entity hit with a depth step; or - the luminance step of the previous frame's output exceeds T. A temporal trigger is optional, and it is history only for the *mask*. 2. Flagged pixels are compacted and trace 3 more rays at a fixed 4-rook (rotated-grid) pattern, world and entity alike. 3. Each extra sample's cell installs/touches the VSC and joins the worklist, so lighting runs **once per new cell, not per sample**. 4. The resolve averages the 4 samples' radiance (with per-sample fog), then ACES. - Averaging before or after ACES is a choice. The reference here averaged after. **Look [M via the 16-spp reference, I for 4 samples].** - G1/G3 stair-steps become a 4-level ramp. - A thin pole is caught whenever any of its 4 samples hits it, so its width stops pulsing between 1 and 2 px. - **The pan excess is mostly at these edge pixels** (§2.3). 4 rooks remove most of the 1-px crawl [I]. **Cost [I].** - Edge share: - silhouettes only: 1-2 % [M]; - colour edges: 1-4 % in the fixtures and the house, **10-17 % on forested terrain** [M]. - × 3 rays. - Rays cost ≈ 1/480 000 of the 0.48-1.08 ms visibility each, ×2-3 for incoherence. - Plus a mask/compaction pass (~0.03 ms) and the worklist's extra cells. - Total: - +0.1-0.35 ms with a silhouette-plus-colour mask in simple scenes; - +0.5-0.9 ms on forested terrain, if colour edges trigger too. - **The terrain case is where B meets its limit.** Most of those colour edges are sub-pixel voxels (G4), and the LoD prefilter or C is the cheaper tool for them. **Motion.** - History-free and identical still or moving. - If the temporal trigger is used, it must make a pixel's state *sticky* (ATAA's rule), so the set of supersampled pixels does not flicker. **Risks.** - Sub-pixel features that all 1-spp neighbours miss are not flagged. That is far G4, and it is what C or the LoD prefilter would address. - The packet tracing (`tileEdgeRd`) must not cull the offset rays. - The worklist capacity must leave room for extra cells. **Prototype plan.** 1. The mask and an extra-sample pass for the world only, behind a flag. Measure the edge share and cost on the poses above plus a terrain pose. 2. Entities, through the same rule. 3. The resolve, then the gate. ### C. Light TAA (rank 3: owner decision; only for what A+B leave) **What.** Jitter the camera basis on the CPU with Halton(2,3), 8 phases, never (0,0). The packet planes must widen by the jitter. Then: - **Motion vectors:** - terrain: hit position → last frame's camera; - entities: the hit's part-local position → the part's **previous pose** (the parts table gains one; every part is treated alike). - **History validation:** cell id (VSC key) + depth within the 3×3 range, NAADF-style. Colour clipping (YCoCg, γ ≈ 1) is used only for lighting changes. - **Accumulation:** per-pixel N, α = max(1/N, 1/12). Disocclusion resets N. - **Placement:** after the resolve (so it sees P2, fog and transparency); before the HUD, the visual cards and the brush overlays. Those need a reactive mask or must draw after it. **Fixes:** the sub-pixel residue (G4, the far end of G2) and the last part of the sweep pop. **Cost:** +0.15-0.3 ms [I], plus one RGBA16F history (3.8 MB at 800×600) and motion vectors. **Motion vs the bar:** - frame 1 = today's image (plausible); - 3 frames ≈ 2× spp; - 12 frames ≈ 8-10 spp. **Rule risks, which the owner should weigh:** 1. Any TAA is a little blurrier in motion than still. Reprojection resampling caps the effective history (Yang §6; Epic). It is continuous, not a switch, but it is still "sharper when still". **Do not** use Bevy's/three.js's still-only confidence ramp. 2. Ghosting on per-cell lighting changes (the sweep flips cells); colour clipping bounds it. 3. Salvi's warning that strongly aliased input flickers under variance clipping. With B in place, the input is no longer strongly aliased. ### D. Spatial only (CMAA2 or SMAA 1x) (rank 4: the cheap fallback) - +0.1-0.25 ms, history-free. - Fixes long stair-steps only. No shimmer fix, no shadow fix. - **It softens the corners of the voxel look.** - Recommended only if B's prototype disappoints on cost. ### The "no temporal" option **A + B (silhouette mask) + the LoD prefilter is a complete history-free answer** for every class measured here, except: - thin features under a pixel that no 1-spp neighbour sees (the antenna at range); and - the last part of the sweep pop's amplitude. Its cost: - ≈ 0.15-0.4 ms; - a far field that is blockier: with `prunePixels` 4, cells never fall below 1 px, so far terrain is one LoD step coarser. The evidence supports trying it before TAA: - the renderer is deterministic when still (T1); - every jaggy class is deterministic; - supersampling silhouettes is cheap because shading is already per cell. What decides between it and C is the terrain look: a coarser but stable far field (prefilter), or full detail averaged over time (TAA). ## 6. Owner sheets (`logs/aa-research/owner/`) | sheet | content | |---|---| | `geometry-current-vs-16spp.png` | crops ×4; columns: current (1 spp), 16-spp reference; rows: the receiver box's top edge, the overview's receiver box and its shadow, two far plates, the 1-voxel pole and the far red/pink plates, the glass pane's edge, the thin rail's shadow | | `shadows-hard-p2-current-vs-16spp.png` | §2.5: rows far plate edge, the box face, the avatar's feet, the pole's shadow, the thin rail; columns hard 1×, hard 16 spp, P2 1×, P2 16 spp, P2 at 4°, vt 46 | | `pan-shimmer-current-vs-16spp.png` | 6 consecutive pan frames (0.26 px a frame); per subject a row at 1 spp and a row at 16 spp: the pole, two far plates, the box face shadow | | `sun-move-current-vs-16spp.png` | 6 consecutive frames of a sun moving 0.02° a frame: the box face and the far floor edge, 1 spp and 16 spp | | `playday-current-vs-16spp.png` | §2.6: indoor sun patch, window frame, house corner, roof antenna, an allay's shadow; columns hard 1×, hard 16 spp, P2 1×, P2 16 spp, vt 10 | | `terrain-current-vs-16spp.png` | §2.4: far terrain on a generated world; columns 1 spp, 16 spp, vt 10 | ## 7. Decisions for the owner 1. **Direction:** prototype **A** (shadows) then **B** (geometry), both history-free? Recommended: yes. 2. **TAA (C):** allowed as a later layer for sub-pixel shimmer, given its unavoidable "slightly sharper when still"? It is continuous, but it is still a still/moving difference. Recommended: decide after A+B are on screen. 3. **Shadow look target:** - a straight hard edge to 1/4 voxel (A2); or - P2's ≤ 2-voxel ramp made smooth (A1 alone)? - Both keep contact hardening. 4. **Far detail:** keep `prunePixels` 2 (cells down to 0.5 px: more detail, more shimmer) or 4 (cells ≥ 1 px: blockier far, no sub-pixel cells, cheaper)? Numbers are in §2.4. 5. **Budget** on the RX 5700 at 800×600 [I]: - A ≈ 0.05-0.25 ms; - B ≈ 0.1-0.35 ms in simple scenes and 0.5-0.9 ms on forested terrain with a colour-edge mask (or ~0.1-0.15 ms silhouettes only); - C would add 0.15-0.3 ms. Within the 0.5-1 ms the owner allowed? On foliage, B with colour edges plus A is at the top of it.