Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ node tools/three/open.ts scenes/bistro.ts # the same scene in three.js, in your
In the window: drag to orbit, right-drag to pan, wheel to zoom, WASD/QE to fly, `R` to reset, `P` for a snapshot.

`play` and `live` take `--quality` (`auto`, `native`, `quality`, `balanced`, `performance`, `ultra-performance`),
`--reconstruction` (`builtin`, `auto`, an upscaler: `fsr`, `metalfx`, `dlss`; a joint denoiser: `metalfx-denoised`,
`dlss-rr`; or a list in order of preference) and `--latency`. FSR 1 also runs on WebGPU; DLSS requires an opt-in NVIDIA
`--reconstruction` (`builtin`, `builtin-upscaler`, `auto`, an upscaler: `fsr`, `metalfx`, `dlss`; a joint denoiser:
`metalfx-denoised`, `dlss-rr`; or a list in order of preference) and `--latency`. FSR 1 also runs on WebGPU; DLSS requires an opt-in NVIDIA
SDK build; MetalFX requires supported Apple hardware. See
[live rendering settings and the TypeScript API](docs/RUNTIME.md#live-rendering-settings).

Expand Down
91 changes: 91 additions & 0 deletions docs/ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -2647,6 +2647,97 @@ Not done. A mesh that comes by an edit (a streamed city's cells are those) is he
come some frames after its build, its instances be placed again, and a mesh that is rebuilt every frame left alone.
wgpu has no refit (`PreferUpdate` builds): a deforming mesh is rebuilt. Not checked on Vulkan.

**The output is composed from guides of its own (2026-12-04, after it).** The entries above found the picture's
error in motion to be the reconstruction's, three to four times what it is at rest. Its cause is where the histories
live: the lighting's are on the traced grid, and the frame's jitter moves every traced sample over its pixel. At an
edge the sample changes surface and under a normal map texel, its histories start again, and the upscaler has the
surfaces of an output pixel only as its history gathers them, which a pixel that moves does not let it. Offline, the
same frames with the lighting kept at half rate and the surfaces given at the output's (eleven moments of two
scenes) had 0.83 to 0.87 of the offline render's detail on the street and 0.72 to 0.80 in the hall, where the
upscaler has 0.68 and 0.58 at rest and 0.39 to 0.47 and 0.37 to 0.46 moving.

- Under a render scale of 1 the frame has two grids (live/frame.rs `decoupled`; docs/RUNTIME.md "ThreeRT's own: the
output composed from its guides"). The kernel's `guides` pass traces the camera's ray for every output pixel each
frame, at one of eight places in the pixel: distance, colour, normal, and the pixel's own light (what it sees
directly; the directional lights' direct light with a shadow ray of its own, so a sun's shadow has the output's
edge). The traced grid's samples stand still, and their histories are of one place. `gcompose` gives an output
pixel the denoised lighting of the traced samples on its surface, times its colour, plus its light; `gupscale`
keeps the output's history, judged by `track`, `judge` and `reject` as the upscaler's is.
- A thing thinner than two output pixels is the output grid's to keep (live.wgsl `Thin`). A guide in nine sees a
lamp a third of a pixel wide; the traced samples, which no longer move, see it always or never, so the upscaler's
locks say nothing here. A guide nearer than both of some pair of opposite neighbours, with no 2 x 2 block like it,
is recorded with its distance and its place, and `gcarry` takes the record on by the two cameras while the guides
of the frames after miss it: the history there moves with the thing, is spared the clamp in motion, and where the
thing has gone on and the frame does not explain the colour left, the history is dropped. upscale/lamps-parallax
at half scale (compose/lamps-parallax-live): beside the sliding field's edge 0.79 of the field's mean light
without the records, 0.003 with them (the upscaler at that scale 0.003); the field in its slide has 1.10 of the
lamps' light (held still 1.06), for the upscaler's 0.33 at that scale and 0.79 at scale 1.
- A setting: reconstruction `builtin` is this where the traced grid is coarser than the output, and the default;
`builtin-upscaler` is the frame as it was (one jitter for every ray, `judge`, `reject`, `upscale`, the locks), and
what `builtin` runs at scale 1 and in a diagnostic view. With `builtin-upscaler` the street's measures and its
frame's time are main's.

Measured on an M4 at half resolution, main → this.

- Two scenes recorded in lockstep at 1280 × 720 while the camera turns, strafes, orbits and stops. The street: the
change of 4 × 4 block means from a frame to the next 0.138 → 0.046 held still, 0.437 → 0.189 after the turn, 0.636
→ 0.302 after the strafe, 0.684 → 0.202 after the stop; per pixel 0.304 → 0.134, 0.543 → 0.262, 0.752 → 0.403,
0.718 → 0.376. Of the offline render's detail 0.681 → 0.776 still, 0.459 → 0.551 mid-turn, 0.467 → 0.578
mid-strafe, 0.387 → 0.477 as the camera stops, along its walk 0.369 → 0.452, 0.412 → 0.539, 0.385 → 0.534; ΔE 2.05
→ 1.92, 2.80 → 2.63, 3.11 → 2.94, 3.52 → 3.33, 3.77 → 3.55, 3.73 → 3.43, 4.64 → 3.95. The hall, its machines
moving throughout: block means 1.411 → 1.435 still, 1.520 → 1.261, 2.217 → 1.798, 2.032 → 1.933, and a moment
after the stop 0.944 → 1.065; per pixel 1.407 → 1.229, 1.763 → 1.090, 2.165 → 1.043, 2.075 → 1.015; detail 0.583
→ 0.645 still, 0.462 → 0.538, 0.407 → 0.505, 0.290 → 0.405 as the camera stops, along its path 0.402 → 0.542 and
0.415 → 0.519; ΔE 3.87 → 3.87, 4.76 → 4.59, 4.80 → 4.79, 5.61 → 5.44, 4.87 → 4.62, 4.12 → 3.88.
- `bench-object-ghosting`: ΔE over the sixteen moments 20 % less in the mean (the device's slide 1.84 → 1.39, the
end of its lift 1.01 → 0.38, the thrown lamp in flight 9.88 → 8.83; the runner 0.41 → 0.43 and, a third of a
second after, 0.30 → 0.33). `bench-temporal --shot edit`: a lamp switched off, its pool settled in 32 frames for
64; switched on, its bounce at 32 frames has 0.925 of its settled light for 0.876; a sign switched off, its floor
at 32 frames ΔE 0.99 for 0.79.
- `bench-ghosting --quick --check` passes, with more excess than main's: mid-turn 0.79 → 1.10 (trail 5 → 10 pixels),
mid-strafe 1.27 → 1.36, half a second after the turn's return 1.03 → 1.30, a tenth of a second after the stop 1.46
→ 1.67 (5 → 11 pixels). Not explained.
- Twelve clips against offline, this build beside main's (main, this, this, main). ΔE: a crowded night street 3.34
→ 3.11, the city 2.04 → 1.87, the hall 3.21 → 3.14, coloured lights 1.25 → 1.21, rooms 0.88 → 0.83, foliage 0.80 →
0.75; a neon street 1.51 both; a home 2.87 → 2.92, metals and gems 2.32 → 2.35, refraction 0.88 → 0.89, a museum
1.28 → 1.29 (not explained). Detail: the crowd 0.491 → 0.593, the hall 0.677 → 0.741, the home 0.923 → 0.996,
coloured lights 0.886 → 0.953, refraction 0.928 → 0.966, the museum 0.886 → 0.955, rooms 0.836 → 0.876, foliage
0.835 → 0.889; the city 0.906 → 1.152 (more than the offline render's own: the measure is a regression on its
gradients, and a picture sharper than the reference's pixels reads over 1); metals and gems 0.311 both; the neon
street 0.715 → 0.693. Whole pixels' change from a frame to the next: less on ten (the home 1.256 → 0.574, the neon
street 0.137 → 0.063, the museum 0.206 → 0.103, the crowd 1.267 → 1.007, the city 0.482 → 0.364), foliage 1.461 →
1.518.
- What it costs: a camera ray an output pixel. A frame's GPU time on the twelve clips 7 to 31 % more: the crowd
10.35 → 13.61 ms, the city 18.24 → 20.43, the neon street 12.40 → 13.58, the hall 11.67 → 14.72, a voxel level
16.68 → 19.37, the home 13.57 → 15.79, coloured lights 14.73 → 15.83, metals and gems 13.43 → 15.04, refraction
11.83 → 13.04, the museum 12.50 → 14.60, rooms 5.43 → 6.62, foliage 11.56 → 13.80. The street at 1280 × 720: 16.3 →
20.5 at rest and 18.2 → 22.0 walking, of which the trace 10.3 → 13.6 and 11.8 → 14.8 (the guides), `gcompose`
0.72, `gcarry` 0.05 and `gupscale` 0.87 (1.10 walking) for `upscale`'s 0.67 (1.02) and `lock_carry`'s 0.09.
Buffers: 60 bytes an output pixel more, 76 where the scene has media.
- The guides are an entry point of the kernel of their own. Run as a mode of `main` they took 6.5 ms on the street
and the crowd's frame was 118 % dearer, not 31: `main`'s weight an invocation, not the rays.
- Under software traversal (`THREERT_HWRT=0`) the street's picture is within 0.005 of this in detail and 0.04 in ΔE,
and the three new render tests pass. Unit suite 298 (one new: a wall's texture of cells two output pixels wide is
in the frame after a cut, lit by an emitter and by a sun, where the traced grid alone has half of it), render suite
280 (three new: the upscaler's three at half scale).

Tried and not kept, each measured: the traced samples kept on the frame's jitter (the same detail in motion, none
of the steadiness at rest); the history following the composition's level everywhere (the street held still
changed 0.41 for 0.046: it follows only while the scene's lighting changes, by 3 % a frame); a rule that takes a
frame whole where it differs much (a bright outlier passes for a lamp switched on: 1.09); the frame without
`track`, `judge` and `reject` (what a moving object leaves behind 28 % further from its settled frame, a lamp's
bounce four times as long to settle); a jitter that keeps each traced sample on its surface, and guides for half
the pixels a frame (no better, or dearer than what they save); the lighting's direction kept with it (no gain
offline); paths only where the lighting's variance asks (97 to 100 % of them would still be traced). At equal frame
time, the lighting's scale lowered to pay for the guides, the picture was a trade (ΔE 5 to 18 % worse; before the
guides had their own pass).

Not done. The guides are traced: rasterised they would cost a fraction, and that is what is left of the frame's
time to gain here. A lamp or a lit window thinner than a pixel that is part of a larger surface has no record (its
distance is its surface's): in motion the clamp cuts its light, as the upscaler's did before its locks. A thing on a
surface that moves by itself is not recorded either. Dynamic resolution pays for the guides with a lower scale: not
measured. Not checked on Vulkan, nor in a browser (both of its modules build).

**The live passes from one place (2026-11-14, after it).** A buffer and a pass more (the locks' carry, above) took
seven edits that had to agree: the declaration in live.wgsl, the bind group layout's entries, the pass list, the
buffers' sizes and order, the bind group's entries, the dispatch grid (in two copies), and the merged layout's table.
Expand Down
38 changes: 34 additions & 4 deletions docs/RUNTIME.md
Original file line number Diff line number Diff line change
Expand Up @@ -1883,7 +1883,7 @@ between what a frame affords and what is shown (renderer/src/live/rendering.rs):
| setting | the gap | ThreeRT's own | vendor technology it maps |
|---|---|---|---|
| `quality` | rays: the render resolution every later stage works from | dynamic resolution | (a budget, not a technique) |
| `reconstruction` | noise, then pixels | denoiser + temporal upscaler | DLSS SR / RR, MetalFX, FSR, XeSS |
| `reconstruction` | noise, then pixels | denoiser + the output composed from its own guides, or a temporal upscaler | DLSS SR / RR, MetalFX, FSR, XeSS |
| `frameGeneration` | frames shown per frame rendered | none | DLSS FG, FSR FG, XeSS FG, MetalFX frame interpolation (none integrated yet) |
| `latency` | input to photon | one frame queued instead of two | Reflex, Anti-Lag 2, XeLL |

Expand Down Expand Up @@ -1911,7 +1911,8 @@ provider, which read different signals:

| `--reconstruction` | denoise | upscale |
|---|---|---|
| `builtin` (default) | ThreeRT | ThreeRT (temporal) |
| `builtin` (default) | ThreeRT | ThreeRT: the output composed from guides of its own (below) |
| `builtin-upscaler` | ThreeRT | ThreeRT's temporal upscaler (what `builtin` runs at scale 1) |
| `fsr` | ThreeRT | AMD FidelityFX Super Resolution **1** (spatial EASU + RCAS; also on WebGPU) |
| `metalfx` | ThreeRT | Apple's temporal scaler (macOS 13+, iOS 16+) |
| `dlss` | ThreeRT | NVIDIA DLSS Super Resolution; DLAA at scale 1 (x86-64 Windows/Linux, RTX on Vulkan, feature `dlss`) |
Expand All @@ -1923,15 +1924,44 @@ provider, which read different signals:

A list (`dlss-rr,dlss,fsr`) is an order of preference; `builtin` ends every list. `quality` presets are the vendors'
ratios exactly (`ultra-performance` is a third: 640 pixels across 1080p, the smallest input DLSS takes, where a typed
`--scale 0.333` gives 639 and DLSS reports itself unsupported). Diagnostic views use `builtin`. A provider that
fails while encoding a frame falls back to `builtin` from that frame on.
`--scale 0.333` gives 639 and DLSS reports itself unsupported). Diagnostic views use `builtin` (they show the traced
grid's buffers, through the upscaler's passes). A provider that fails while encoding a frame falls back to `builtin`
from that frame on.

A provider says which render scales it takes (`scale_range`: MetalFX scales its output up to 3x the input, so a third
and up; DLSS from its modes' input ranges). Under dynamic resolution (`quality: auto`) the governor does not go below
the range of the method that runs, nor below that of the first method asked for that did not run for the scale alone:
it goes up to it, and from there the method runs. (A 2560 x 1440 view that dynamic resolution held at a quarter never
ran MetalFX before.)

### ThreeRT's own: the output composed from its guides

Under a render scale of 1 a frame has two grids, and `builtin` gives each what it is for (live/frame.rs `decoupled`):

- **The output grid has the camera's rays.** Every frame the kernel's `guides` pass traces the camera's ray for
every *output* pixel, at the frame's place in the pixel (8 places): the surface's distance, colour and normal, and
the light that is the pixel's own (what it sees directly, a sky, the directional lights' direct light with their
shadow ray). A mirror's pixel has the surface it shows.
- **The traced grid has the lighting.** Its samples stand at their pixels' centres (no jitter), so each keeps one
surface, and one texel of it, while the camera holds still, and the denoisers' histories are of one place.
- **`gcompose`** gives each output pixel the denoised irradiance and specular light of the traced samples around it
that lie on its surface (by its plane and its normal), times its own colour, plus its own light, behind the medium
the traced samples' rays were marched through.
- **`gupscale`** keeps the output's history: a frame counts by where its guide lay in the pixel at rest and whole
when the pixel moves; `track`, `judge` and `reject` judge the history as they judge the upscaler's.
- **Thin things** (live.wgsl `Thin`): a thing thinner than two output pixels that a guide saw is recorded with its
distance and carried by the two cameras while the guides of the frames after miss it (`gcarry`): its light goes
with it and not with what is behind it, and is not cut by the clamp in motion.

`builtin-upscaler` is the frame as it was before: the camera's rays at the render resolution alone, one jitter for
every ray, and the temporal upscaler (`judge`, `reject`, `upscale`, the thin features' locks). At scale 1 the two
grids are one and `builtin` runs those passes too. Both run with ray queries and with software traversal.

What it costs is the guides: a camera ray an output pixel (Bistro at 1280 × 720 and half resolution on an M4: 3.3 ms
of a frame of 20.5; the output's passes take 1.7 ms where the upscaler's took 0.8), and 60 bytes an output pixel more
of buffers (the guides 32, the composition 16, the thin things' records 12; 16 more where the scene has media: 55 MB
at 1280 × 720). docs/ROADMAP.md § 1a has what it gives for that.

### TypeScript

```ts
Expand Down
5 changes: 3 additions & 2 deletions packages/scene/src/rendering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* src/live/rendering.rs has the whole table):
*
* - `quality`: how many rays, as the render resolution (`"auto"`: dynamic resolution).
* - `reconstruction`: the noise and the missing pixels. ThreeRT's own denoiser and upscaler (`"builtin"`), an upscaler
* - `reconstruction`: the noise and the missing pixels. ThreeRT's own denoiser, and the output composed from the
* camera's rays for every output pixel (`"builtin"`) or its temporal upscaler (`"builtin-upscaler"`); an upscaler
* that replaces only the upscaling (`"dlss"`, `"metalfx"`, `"fsr"`), or a joint denoiser that replaces both and
* reads the noisy signal itself (`"dlss-rr"`, `"metalfx-denoised"`). A list is an order of preference.
* - `frameGeneration`: frames shown per frame rendered (none is integrated yet: it reports itself unavailable).
Expand All @@ -14,7 +15,7 @@
*/

/** One way of reconstructing the frame. `custom:<id>` names a provider the embedding renderer registered. */
export type ReconstructionMethod = "builtin" | "off" | "fsr" | "metalfx" | "metalfx-denoised" | "dlss" | "dlss-rr" | `custom:${string}`;
export type ReconstructionMethod = "builtin" | "builtin-upscaler" | "off" | "fsr" | "metalfx" | "metalfx-denoised" | "dlss" | "dlss-rr" | `custom:${string}`;
export type ReconstructionRequest = "auto" | ReconstructionMethod | readonly ReconstructionMethod[];
export type QualityRequest = "auto" | "native" | "quality" | "balanced" | "performance" | "ultra-performance" | number;
export type FrameGenerationRequest = "off" | "auto" | "2x" | "3x" | "4x";
Expand Down
Loading