diff --git a/README.md b/README.md index df3834f4..33aaac97 100644 --- a/README.md +++ b/README.md @@ -9,23 +9,21 @@

ThreeRT

-

The native runtime for three.js — hardware path tracing at 60 fps, or a clean WebGPU app.

+

three.js, down to the metal.

-

- One engine, two renderers: path traces every light on ray-tracing hardware at 60 fps,
- and webgpu (macOS & Linux, architecture) runs standard three.js natively with zero path-tracer code. -

+

ThreeRT is a native runtime for three.js: no browser between your scene and the GPU.

CI @threert/scene on npm MIT licence - Clients for macOS and iOS + Clients for macOS, iOS, Steam Deck and Android Discord

Website · + Blog · Apps · Download · Docs · @@ -34,66 +32,39 @@

- Twelve scenes path-traced live by ThreeRT: Bistro at night with a crowd, OpenStrike, Tokyo at dusk, Beeple's Zero-Day, a voxel city demolished, glowing balls down a staircase, a wrecking ball through a tower of glowing bricks, 400 lanterns, and product and interior scenes -
- ThreeRT, live on an Apple M3 Max: this repository's demos and OpenStrike, a shooter built on the engine, on its own map. + three.js, down to the metal: 45 times smaller than Electron, on a Sony PS3, ray-traced at 60 fps

-## Three + RT +## Down to the metal -**Three**, for the API you already know. **RT**, for the three things it adds: +Take the browser out from under three.js, and three things open up. -- **Ray tracing.** Every light is traced: shadows, bounce light, reflections, and glowing surfaces that light the room. No shadow maps, no light probes, no lightmaps, no baking. -- **Real time.** 60 fps in production scenes with the camera moving: Amazon Lumberyard Bistro and Beeple's Zero-Day, on a laptop. Not a still that converges once you stop. -- **Runtime.** A native runtime for three.js, not only a renderer. Scene code and game logic run inside the engine: choose the `path` renderer for hardware ray tracing, the `webgpu` renderer (`node tools/build.ts --renderer webgpu`) for a clean native app with zero ray-tracing overhead, or run as plain three.js in any browser. +- **45× smaller.** `webgpu` (macOS and Linux) runs three.js r187 and its own `WebGPURenderer`, unchanged, on a native `navigator.gpu` over wgpu, with the same pixels as Chrome. A desktop app is 9.9 MB installed where its Electron build is 445 MB; a three.js wallpaper on Wayland uses 15.6 % CPU where Chromium uses 39.9 %, and none while a window covers it. +- **On a Sony PS3.** On hardware with no WebGPU and no JIT, three.js r187's scene graph runs on QuickJS and a native renderer draws it on the RSX at 1920 × 1080, with a PocketJS interface in the same frame. Experimental, 16 to 30 fps: [three.js on a Sony PS3](https://threert.dev/blog/ps3/). +- **Ray-traced, 60 fps.** On GPUs with ray-tracing hardware, `path` traces every light in a three.js-style scene: shadows, bounce light, reflections and glowing surfaces, nothing baked, at 60 fps in production scenes. -## Renderers: `path` and `webgpu` +**Three + RT:** Three, for the API you already know; RT, for ray tracing, real time, and the runtime under both. -ThreeRT stays one engine and one runtime with two renderers selected at build time (`node tools/build.ts --renderer path` or `--renderer webgpu`). They share the native runtime (`runtime/`) with one-way dependencies (`threert-path → threert-runtime ← threert-webgpu`), enforced by CI (`node tools/check-webgpu-gate.ts`) so a `webgpu` build links no ray-tracing code at all. +## Renderers: what each keeps of three.js -| | `path` | `webgpu` ([`docs/RENDERING-METHODS.md`](docs/RENDERING-METHODS.md)) | -|---|---|---| -| **Renderer** | Rust + wgpu compute path tracer (hardware ray queries, OIDN, DLSS / MetalFX) | Standard three.js `WebGPURenderer` over native `navigator.gpu` (wgpu) | -| **Scene API** | `@threert/scene` (physical lighting units) | Plain `three.js` + TSL node materials (+ PocketJS UI) | -| **GPU** | Ray-tracing hardware (Apple M-series, RTX, RDNA2+) | Any GPU wgpu supports (Metal, Vulkan, D3D12) | -| **Footprint** | Full ThreeRT clients | Proven at **9.9 MB installed / 4.5 MB download** (vs 445 / 170 MB Electron) | - -## Hello world looks right - -Write a scene at tutorial size and leave every setting at its default. - -```ts -import { Scene, PerspectiveCamera, Mesh, BoxGeometry, MeshStandardMaterial, DirectionalLight, SkyAtmosphere } from "@threert/scene"; - -export default function build() { - const scene = new Scene(); - const sun = new DirectionalLight(0xffffff, 90000).setSunAngles(28, 100); // lux - scene.add(sun); - scene.environment = new SkyAtmosphere({ sun }); - - const plaster = new MeshStandardMaterial({ color: 0xd9d4cc, roughness: 0.92 }); - const wall = new Mesh(new BoxGeometry(6.6, 3, 0.3), plaster); - wall.position.set(0, 1.5, -3.15); - scene.add(wall); - // ... the rest of the room: a floor, a window, a sofa, a lamp - - const camera = new PerspectiveCamera(58, 16 / 9, 0.05, 200); - camera.position.set(-2.3, 1.45, 2.4); - camera.lookAt(1.0, 0.9, -1.2); - scene.add(camera); - return { scene, camera }; -} -``` +Each way of running a three.js project keeps part of three.js and replaces the rest. In this repository, two renderers are selected at build time (`node tools/build.ts --renderer path` or `--renderer webgpu`). They share the native runtime (`runtime/`) with one-way dependencies (`threert-path → threert-runtime ← threert-webgpu`), enforced by CI (`node tools/check-webgpu-gate.ts`) so a `webgpu` build links no ray-tracing code at all. A third way, a native renderer for three.js's scene graph, runs on a PlayStation 3 and is built in PocketJS. -| three.js, as written | ThreeRT, all defaults | -|---|---| -| ![A room in three.js: flat walls, no sunlight on the floor](site/media/hello/sun-room-three.webp) | ![The same room in ThreeRT: sunlight through the window, bounce light on the walls](site/media/hello/sun-room-rt.webp) | +| | `path` | `webgpu` ([`docs/RENDERING-METHODS.md`](docs/RENDERING-METHODS.md)) | PlayStation 3 (experimental) | +|---|---|---|---| +| **Keeps of three.js** | Its scene API, as `@threert/scene` (physical lighting units) | three.js and its `WebGPURenderer`, unchanged, + TSL node materials | The scene graph: objects, geometry, materials, lights | +| **Replaces** | The renderer, with a path tracer | The browser, with the native runtime | three.js's renderer, with a native one | +| **Renderer** | Rust + wgpu compute path tracer (hardware ray queries, OIDN, DLSS / MetalFX) | three.js r187 `WebGPURenderer` over native `navigator.gpu` (wgpu) | C on the RSX, hand-written PBR, sky and unlit shaders; three.js r187 on QuickJS (no JIT) | +| **GPU** | Ray-tracing hardware (Apple M-series, RTX, RDNA2+) | Any GPU wgpu supports (Metal, Vulkan, D3D12) | The PlayStation 3's RSX, 1920 × 1080 | +| **UI** | The game HUD | PocketJS over the 3D frame | PocketJS in the same frame | +| **Footprint** | Full ThreeRT clients | Proven at **9.9 MB installed / 4.5 MB download** (vs 445 / 170 MB Electron); also a Wayland wallpaper host (`webgpu/wallpaper`) | 16–30 fps in four demos, not yet profiled; in [PocketJS](https://github.com/pocket-nexus/pocketjs/tree/main/programs/ps3), not built by `tools/build.ts` | + +### A native renderer for the scene graph -The sun through the window, the sky, the bounce light off the floor and the lamp's glow come from tracing the scene. Light is in physical units: the sun is 90,000 lux, and an emissive surface is a light source. The whole file is [`scenes/sun-room.ts`](scenes/sun-room.ts). +three.js's `WebGPURenderer` needs WebGPU, and it does its per-frame work in JavaScript, which runs several times slower without a JIT. A PlayStation 3 has neither WebGPU nor a JIT. There the scene code still imports `three` and builds a three.js scene graph; once a frame, a small renderer walks the graph, packs each object's transform and material into typed arrays, and hands them to native code that draws on the RSX. three.js's own renderer never runs, so what lives in it does not carry over: shadows, `ShaderMaterial` and TSL, three.js's post-processing. This sits between `webgpu`, which keeps all of three.js, and a [port](docs/PORTS.md), which keeps only a game's rules. [`docs/RENDERING-METHODS.md`](docs/RENDERING-METHODS.md) has what it draws and what it costs. -## Against three.js at full power +## Ray-traced: against three.js at full power -The same scene file, run by both engines on the same Mac. three.js gets everything it has: shadow maps, image-based lighting and, on WebGPU, its own SSGI, SSR and TRAA. +On GPUs with ray-tracing hardware: the same scene file, run by both engines on the same Mac. three.js gets everything it has: shadow maps, image-based lighting and, on WebGPU, its own SSGI, SSR and TRAA. | three.js r187 | ThreeRT | |---|---| @@ -110,9 +81,23 @@ The reference is an unbiased offline render (4,096 samples per pixel, no denoise ## Get started -### Play and make games +### Run three.js natively (`webgpu`, macOS and Linux) + +```bash +npm install +node tools/build.ts --renderer webgpu # the runtime and the webgpu renderer; no path-tracer code is linked +node tools/check-webgpu-gate.ts --render # dependency isolation, JS layering, binary size, a headless render +``` + +The sample is plain three.js and TSL ([`webgpu/sample/scene.ts`](webgpu/sample/scene.ts)); the Omarchy wallpaper host is [`webgpu/wallpaper`](webgpu/wallpaper). How it is built and measured: [`docs/RENDERING-METHODS.md`](docs/RENDERING-METHODS.md). + +### three.js on a Sony PS3 + +The PS3 runtime and its three.js renderer are built in [PocketJS](https://github.com/pocket-nexus/pocketjs/tree/main/programs/ps3), with PSL1GHT, for a console with custom firmware. How it works and what it measured: [three.js on a Sony PS3](https://threert.dev/blog/ps3/). + +### Play and make games (`path`) -1. **[Download ThreeRT](https://threert.dev/download/)** for macOS (14 or later, Apple silicon) or iPhone and iPad (iOS 17 or later). The client fetches a game's code and traces it on the device's own GPU. +1. **[Download ThreeRT](https://threert.dev/download/)** for macOS (14 or later, Apple silicon), iPhone and iPad (iOS 17 or later), Steam Deck or Android. The client fetches a game's code and traces it on the device's own GPU. 2. Open an example from the app's library or from [threert.app](https://threert.app), where ThreeRT apps and games are published. 3. Write your own with the `threert` command line that ships inside the Mac app: @@ -194,18 +179,21 @@ npm run test:render # the r | Directory | What | |---|---| | [`renderer/`](renderer) | The engine: the Rust + wgpu path tracer, live viewport, denoiser, post, and an embedded QuickJS that runs scene code (`threert-render`); `voxel-core` and `physics-core` (Rapier) also build for wasm32 | +| [`runtime/`](runtime) | The native runtime: the JavaScriptCore guest, web-platform globals (timers, fetch, WebSocket, storage, Canvas 2D), and the PocketJS host | +| [`webgpu/`](webgpu) | The `webgpu` renderer: `navigator.gpu` over wgpu, the sample, the headless `webgpu-shot`, and the Wayland wallpaper host | | [`packages/`](packages) | `@threert/scene`, `@threert/gameplay`, `@threert/voxel` | | [`scenes/`](scenes), [`games/`](games) | The reference catalog (Cornell box, material grid, Bistro, Zero-Day, …) and the playable content | | [`tests/`](tests) | The render test suite (analytic and temporal checks) and the three.js compatibility set | | [`tools/`](tools) | Bundling, benches and gates, the three.js comparison, the Tokyo pipeline | | [`compare/`](compare) | Hello-world scenes side by side in three.js and ThreeRT | | [`ue5/`](ue5) | UE5 reference captures (Lumen and the Path Tracer): the ground truth the renderer is measured against | -| [`site/`](site) | [threert.dev](https://threert.dev): the landing page, Download and Docs (the apps themselves are on [threert.app](https://threert.app)) | +| [`site/`](site) | [threert.dev](https://threert.dev): the landing page, the blog, Download and Docs (the apps themselves are on [threert.app](https://threert.app)) | ## Documentation - [Getting started](https://threert.dev/docs/): the client, a first scene, the dev loop, packages -- [`docs/RENDERING-METHODS.md`](docs/RENDERING-METHODS.md): one runtime, two renderers (`path` and `webgpu`), crate layout and size-gate rules +- [Blog](https://threert.dev/blog/): engineering notes; the first is [three.js on a Sony PS3](https://threert.dev/blog/ps3/) +- [`docs/RENDERING-METHODS.md`](docs/RENDERING-METHODS.md): what each way of running keeps of three.js: the `path` and `webgpu` renderers, native scene-graph renderers, crate layout and size-gate rules - [`docs/RUNTIME.md`](docs/RUNTIME.md): how scene code runs in the engine: setup, handlers, world handlers, frame scripts, physics - [`docs/MATERIAL_FUNCTIONS.md`](docs/MATERIAL_FUNCTIONS.md): a WGSL body on a material, run by the path tracer at every hit - [`docs/VOXEL.md`](docs/VOXEL.md): the voxel engine, measured on a destructible level diff --git a/docs/RENDERING-METHODS.md b/docs/RENDERING-METHODS.md index 41bac6a8..86986f05 100644 --- a/docs/RENDERING-METHODS.md +++ b/docs/RENDERING-METHODS.md @@ -1,4 +1,4 @@ -# Renderers: Path Tracer (`path`) and WebGPU (`webgpu`) +# Renderers: Path Tracer (`path`), WebGPU (`webgpu`), and native scene-graph renderers > Status: active (2026-11-28). Both the `path` renderer (`renderer/`) and the `webgpu` renderer > (`runtime/` + `webgpu/`, built via `node tools/build.ts --renderer webgpu`, gated by @@ -7,11 +7,19 @@ > runs three.js r187's `WebGPURenderer` natively on PocketJS's JavaScriptCore guest > (`pocket-nexus/pocketjs#773`, `#774`, `#775`), originally proven in > `pocket-nexus/pocket-agents-island#28`, `#29`. Windows support remains planned. +> A native renderer for three.js's scene graph runs, experimentally, on a **PlayStation 3** (2026-12-02). +> It is built in PocketJS, not in this repository: [Native scene-graph renderers](#native-scene-graph-renderers). -ThreeRT is one engine and one runtime with **two renderers**, chosen per project and per build: +ThreeRT is one engine and one runtime with **two renderers** in this repository, chosen per project and +per build. They differ in what they keep of three.js: `path` keeps its scene API and replaces the renderer; +`webgpu` keeps three.js and its renderer and replaces the browser. A third way, for hardware with neither ray +tracing nor WebGPU, keeps three.js's scene graph and replaces its renderer +([below](#native-scene-graph-renderers)). | | **`path`** (Path Tracer) | **`webgpu`** (WebGPU — macOS & Linux) | |---|---|---| +| Keeps of three.js | its scene API, as `@threert/scene` | three.js and its `WebGPURenderer`, unchanged | +| Replaces | the renderer | the browser | | What draws | ThreeRT's wgpu compute path tracer: hardware ray queries, OIDN, DLSS / MetalFX, the physical sky and post chain | three.js r187's own `WebGPURenderer`, running natively: `navigator.gpu` implemented over wgpu inside the engine's JavaScript guest | | Scene code | `@threert/scene` (physical units) | plain `three.js` + TSL node materials | | GPU | ray-tracing hardware (Apple M-series, RTX, RDNA2+) | any GPU wgpu supports (Metal, Vulkan, D3D12) | @@ -91,6 +99,50 @@ the `dlss` / `oidn` / `net` / `audio` features, and the default build stay as th The JavaScriptCore guest and native text path live in PocketJS (`pocket-guest-jsc`, `pocket-wgpu-render`'s `TextPainter`); ThreeRT depends on them rather than copying them. +## Native scene-graph renderers + +`webgpu` needs two things from a device: a GPU that wgpu drives, and a JavaScript engine fast enough for +`WebGPURenderer`'s per-frame work. A PlayStation 3 has neither: its RSX predates WebGPU's feature set, and +homebrew has no JIT (PocketJS runs QuickJS on the Cell's PPU). There a native renderer draws three.js's scene +graph instead of three.js's own renderer: + +- The scene code is unchanged three.js: it imports `three` (0.187.0) and builds `Object3D`s, geometries, + materials and lights. +- Once a frame, `RSXRenderer` (TypeScript, about 800 lines) calls `updateMatrixWorld`, walks the graph, and + packs each object's matrix and material parameters into typed arrays. Geometry and textures are uploaded + once and cached by id. +- Native code (`rsx3d.c`) draws them on the RSX with three hand-written shader pairs: PBR (metalness and + roughness, an environment map, a directional, a hemisphere and three point lights, fog), a sky dome, and + unlit points and lines. A planar mirror uses the stencil buffer. +- PocketJS draws its UI into the same 1920 × 1080 frame after the 3D pass, without a clear. + +What it draws: `Mesh`, `InstancedMesh`, `Points`, `Line` and `LineSegments`; `MeshStandardMaterial`, +`MeshPhysicalMaterial`, `MeshPhongMaterial`, `MeshLambertMaterial`, `MeshBasicMaterial` and +`MeshNormalMaterial`, mapped onto the PBR or the unlit shader; ambient, hemisphere, directional and point +lights; `Fog` and `FogExp2`; `PerspectiveCamera`. What lives in three.js's renderer does not carry over: +**shadows, `ShaderMaterial`, `onBeforeCompile` and TSL, render targets and post-processing**. The mirror is +the renderer's own option, not three.js's `Reflector`. + +Measured on a PlayStation 3 (CECH-2500, system software 4.81 with custom firmware), 1920 × 1080, from the +demos' own counters. "Submit" is PPU time spent writing the 3D pass's commands, not GPU time. + +| Demo | Triangles | Draws | Submit | fps | +|---|---:|---:|---:|---:| +| Showroom: torus knot, PBR satellites, planar mirror | 25,990 | 26 | 0.1 ms | 20 | +| Material grid: 20 spheres, metalness × roughness, mirror | 58,886 | 43 | 0.1 ms | 26 | +| Galaxy: planet, rings, 2,400 point sprites | 5,678 | 7 | 0.1 ms | 30 | +| Instanced wave: 196 instances | 2,362 | 199 | 28.9 ms | 16 | + +The RSX has no hardware instancing, so an `InstancedMesh` costs one draw and one constant upload an instance: +that is the 28.9 ms. Where the other demos' frames go (QuickJS walking the graph, the RSX shading 1080p with +a mirror pass, or waiting on vsync) is **not measured yet**, and the Cell's six SPUs are not used. + +It is not a `--renderer` of this repository. It shares no crate with `runtime/`: the PS3 build is PocketJS's +(PSL1GHT, `ppu-gcc`, a C host program), and the code is in `pocket-nexus/pocketjs` (`platforms/ps3/`, +`apps/ps3-three-showcase/`). A shared interface for scene-graph renderers waits for a second device that needs +one. It sits between `webgpu`, which keeps all of three.js, and a [port](PORTS.md), which keeps a game's rules +and replaces everything else. + ## Open questions - **The guest on Windows and Linux.** three.js's `WebGPURenderer` does per-frame work in JavaScript; diff --git a/docs/images/hero.webp b/docs/images/hero.webp new file mode 100644 index 00000000..6dceb1ca Binary files /dev/null and b/docs/images/hero.webp differ diff --git a/docs/images/social-preview.jpg b/docs/images/social-preview.jpg new file mode 100644 index 00000000..ec9798f4 Binary files /dev/null and b/docs/images/social-preview.jpg differ diff --git a/site/README.md b/site/README.md index 5a55f24b..8548a853 100644 --- a/site/README.md +++ b/site/README.md @@ -48,10 +48,10 @@ Two things are asked of a visitor, on every page: **a star** on github.com/meshy a page for each app at `.threert.app`, `threert publish`, multiplayer rooms). threert.dev says what the engine is and proves it; the apps live there. So the site has no catalogue of its own. -Every page has the same nav, top right: **Apps** (threert.app, in the same tab and without an external-link arrow: the platform is the same product, its own nav leads back to Download and Docs here, and a new tab costs the back button on phones), -**Download**, **Docs**, then **Star** (GitHub's mark, the word and the repository's star count: `a.star`, below), +Every page has the same nav, top right: **Blog** (`blog/`), **Download**, **Docs**, then **Star** (GitHub's mark, the word and the repository's star count: `a.star`, below), Discord (discord.gg/n7vsVmAKCK) and X (x.com/ThreeRT3D) as their marks; on a phone Star is GitHub's mark alone. The -footer has the same links, over the line that says whose it is: a research project from MeshyAI (meshy.ai), © MeshyAI. +footer has the same links and **Apps** (threert.app, in the same tab and without an external-link arrow: the platform is +the same product), over the line that says whose it is: a research project from MeshyAI (meshy.ai), © MeshyAI. The markup is repeated in each page; change it in all of them (the privacy page has the three words only). | Page | What is on it | @@ -59,45 +59,56 @@ The markup is repeated in each page; change it in all of them (the privacy page | `index.html` | The landing page (below). | | `download/` | The five clients, a card each (below), then how a client loads a game: `threert dev`, scan, traced and live. | | `docs/` | Getting started: install the client, open an example, write a scene, the dev loop with the `threert` CLI, the package format and publishing to threert.app, links to the reference documents in `docs/` on GitHub. | +| `blog/` | The blog: an index (`blog/index.html`, a row per post, newest first) and a directory a post (`blog/ps3/`). A post is the docs article layout (contents on the left) with its own figures drawn in HTML and SVG, its own `og:image` and `og:type` article. The first: three.js on a Sony PS3. | | `privacy/` | What the apps and the site do with data, including the requests the pages make to other services (below). | | `showcase/` | Gone as a page: what it listed is published on threert.app. The Worker answers `/showcase`, `/showcase/` and `/showcase/index.html` with a 301 to `https://threert.app/` (old links: the npm packages' READMEs, the pages of packages built before, earlier apps); `showcase/index.html` is what is left for a host without the Worker, a page that sends the reader on. `showcase/community.json` stays where it is, served as before: ThreeRT for macOS before 0.4.0 reads it (and `play/index.json`) for its Showcase. Nothing is added to it any more: people publish with `threert publish`. | ### The landing page -The buttons, in the hero and at the end, in this order of weight: **Explore apps** (filled, to threert.app), **Star on -GitHub** (outlined, with the count), and under them a line with **Download** as a link, named for the visitor's -platform by `js/site.js` (`a[data-dl]`), then the other clients in a word each (`[data-dl-others]`: "Download for -macOS · iPhone · Steam Deck · Android"). One filled button a row; three equal buttons were the thing to avoid, and -the clients do not get buttons here. - -1. **Hero:** a reel behind the headline: a grid of short clips of this repository's demos (Bistro with a crowd, - Tokyo at dusk, Zero-Day, the voxel city demolished, the showreel's light-and-physics scenes, the showcase cases) - and of OpenStrike on its own map, all ThreeRT live, ray traced, - nothing compared (`media/reel/`: 4 x 3 clips for a wide screen, 2 x 4 for a phone held upright; 60 fps, an 8 s - loop). Nothing in it takes a touch, so a finger scrolling the page passes over it. Its first frame is what shows - until it plays, and where it does not: reduced motion, a data saver, autoplay refused. A button pauses it. - "Hardware ray-traced three.js." -2. **ThreeRT = Three + RT:** Ray Tracing, Real Time, Runtime. -3. **Hello world looks right:** an auto-advancing reel of three starter scenes, the ThreeRT source next to its output - (three.js as written | ThreeRT with every setting at its default). -4. **Against three.js at full power:** Bistro night and Zero-Day; the left side picks three.js WebGL, three.js WebGPU - with SSGI, or the path-traced reference; the right side is ThreeRT live. -5. **A camera move:** Bistro night as a clip under a divider (three.js | ThreeRT at 60 fps, `media/bistro/hero*.mp4`: - both sides in one file so they cannot drift; it was the Showcase page's opening) and Zero-Day's camera path, 60 - poses of both engines in lockstep. -6. **What a ray finds:** four close-ups. -7. **Open source. MIT.** A strip, where the comparisons end: what is in the repository, why a star helps, the Star - button, the npm packages. -8. **One runtime, two renderers, every screen:** the `path` renderer on ray-tracing hardware, the planned `webgpu` - renderer for clean native three.js apps with zero ray-tracing code, and the same scene in any browser or WebView. -9. **Play it with a friend:** OpenStrikeRT (`https://openstrike.threert.app/`), the platform's first multiplayer game: - its cover with the words over it, two of its screenshots, three facts (rooms of up to 10, bots when alone, all of it - game code). Its pictures are copies in `media/openstrike/`. -10. **Not only games. All on threert.app:** seven apps from the platform and an eighth cell that invites the reader's - own (next section). -11. **One command puts yours online:** write three.js-style code, `threert publish`, the app's address. What it says - `threert publish` does is what https://threert.app/publish says; check there before changing it. -12. **Just light.** +One line and what it means: **three.js, down to the metal**, with no browser between three.js and the hardware. The page +is short on purpose: the first screen +says all of it, and each section after proves one card of it. Nothing on it is said twice. + +**Light.** The page is unlit ink behind a sheet of glass, with light flowing under it (`js/glass.js`, one WebGL2 +fragment shader on a fixed canvas behind everything). The sheet is a low-poly mesh of irregular triangles, about 96 px +each. Every triangle is a facet with its own tilt: it shows the light behind it shifted, shades across its thickness, +and now and then catches a moving glint; its edges catch the light where there is any. The light is the hero's: a warm +key behind the headline, a cool rim top right and a warm bounce under the cards, with a domain-warped flow running +through them; it moves off slower than the page scrolls, and a little warm light follows a mouse. The shader draws at +most 30 frames a second, below the screen's resolution, nothing while the tab is hidden, and one still frame under +reduced motion. Without WebGL2 the hero keeps the same light in CSS (`html:not(.glass-on) .hx::before`, `::after`). +Over the sheet: a highlight runs across "down to the metal." every 9 s; the cards have a specular top edge and glow in +their own colour on hover; each section is lit in its answer's colour behind what it shows (`#light` silver-blue, +`#far` the PlayStation 3's blue, `#traced` and the end tungsten). Warm light is tungsten, the one accent, and means +light; nothing else uses it. + +The buttons, in the hero and at the end: **Explore apps** (filled, to threert.app) and **Star on GitHub** (outlined, +with the count). One filled button a row. The end adds one line of links: the repository, **Download** (named for the +visitor's platform by `js/site.js`, `a[data-dl]`) and the docs. + +1. **Hero:** "three.js, down to the metal." (the headline), under it what ThreeRT is ("ThreeRT is a native runtime for + three.js: no browser between your scene and the GPU."), the buttons, and three cards, each a picture, a few words + and a footnote: **45× smaller** (the `webgpu` wallpaper; footnote 1), **On a Sony PS3** (footnote 2), **Ray-traced, + 60 fps** (Bistro path-traced, on GPUs with ray-tracing hardware; footnote 3). Say "Sony PS3" or "Sony PlayStation + 3", never "a 2006 console"; and say where tracing happens (the path renderer, ray-tracing GPUs), never that + everything is traced. Each card leads to its section. +2. **Ship it like a native app** (`#light`, `webgpu`): one paragraph, three numbers (installed size against Electron, + CPU against Chromium, CPU while covered), the Omarchy wallpaper (`media/webgpu/`, from doodlewind/ThreeRT-dev#8; + the Earth is NASA's Blue Marble and Black Marble). +3. **No WebGPU. No JIT. It still runs.** (`#far`, the Sony PS3, experimental): one paragraph that says what it is and + what it can't do yet, two frames from the console (`media/ps3/`), a link to the blog post on the port + (`blog/ps3/`). The code is in PocketJS. +4. **Ray-traced. At 60 fps.** (`#traced`, `path`): the one comparison with three.js at full power: Bistro night + or Zero-Day; the left side picks three.js WebGL, three.js WebGPU with SSGI, or the path-traced reference; the right + side is ThreeRT live. Under it one line of numbers and the clients it runs in. +5. **Made with ThreeRT. On threert.app.** Seven apps from the platform and an eighth cell that invites the reader's + own (`threert publish`). +6. **Bring your three.js.** The mark, the buttons, the line of links. + +Taken off this page in the rewrite, and still in the repository: the reel (`media/reel/`, `site/tools/reel.ts`; its +still is `docs/images/reel.webp`), the hello-world reel (`media/hello/`, `media/code/`), the camera moves (`media/bistro/hero*`, +`media/*/move/`), the 3D device shelf (`js/devices.js`, `media/devices/`) and OpenStrikeRT's section +(`media/openstrike/`, still written by `site/tools/platform.ts`). ### The Download page @@ -220,8 +231,9 @@ where it is served: | `js/threert.js` | The wipe comparison (and the clip that can play over its two stills), the reel behind the landing page's headline, the synced camera-move player, the code highlighter. A divider follows a finger only once it moves sideways, so scrolling past one does not move it | | `js/site.js` | What the pages share: the visitor's platform (macOS, iPhone, Android, Linux x86_64), the clients released on this host, the Star buttons' count, QR codes | | `js/platform.js` | threert.app on the landing page: which apps are shown, and a tile's markup (shared with `tools/platform.ts`) | -| `js/devices.js` | The 3D device rows (three.js), with a still fallback when WebGL is off | -| `brand/card.jpg` | The share card (Open Graph, 1200 x 630): the hero's headline over the reel's still, a screenshot of the page with the nav's links, the lede and the buttons hidden | +| `js/devices.js` | The 3D device rows (three.js), with a still fallback when WebGL is off (no page uses them now) | +| `js/glass.js` | The landing page's background: a sheet of glass triangles over a flowing light, one WebGL2 fragment shader on a fixed canvas; adds `glass-on` to `` when it draws | +| `brand/card.jpg` | The share card (Open Graph, 1200 x 630): a screenshot of the hero (the headline, the line under it and the three cards; the nav's links, the buttons and the footnote marks hidden). The same screenshot is the README's picture (`docs/images/hero.webp`, at 2x) and GitHub's social preview (`docs/images/social-preview.jpg`, 1280 x 640, uploaded in the repository's settings: the API cannot set it) | | `brand/` | The mark ("Three bounces": the three.js triangle, tilted as three.js draws it, and the closed light path inside it, which is three.js's own inner triangle) and its variants. `js/mark.js` draws it live in the lockup and on the landing page, and turns the path on hover. `avatar.svg` is the profile picture (X, Discord): the mark on black for a round crop, its triangle concentric with the circle, heavier strokes (4.2 against 3.2) so it holds at 32 px | | `media/` | The renders, WebP, and the clips (the reel, the Bistro comparison), H.264. Generated; never retouched | | `serve.ts`, `tools/` | Local server, static build, deploy, media and device-still generators; `tools/platform.ts` bakes threert.app's apps and OpenStrikeRT's pictures into the landing page; `tools/vendor.ts` names the npm files the pages import (three.js, qrcode-generator) | @@ -238,7 +250,7 @@ bun site/tools/media.ts # out/ -> site/media (stills, camera-move fra bun site/tools/device-stills.ts # the 3D device rows -> site/media/devices (headless Chrome, software WebGL) ``` -The landing page's reel is recorded on the machine at hand, a clip a demo (`node tools/site-reel.ts` lists them and +The reel (off the landing page since the rewrite; kept for other uses) is recorded on the machine at hand, a clip a demo (`node tools/site-reel.ts` lists them and what each needs: Bistro and the Quaternius mannequin, the Tokyo tiles, `tools/voxel-level/generate.ts` at mesh, region and object granularity, Zero-Day), then laid out and encoded: diff --git a/site/blog/index.html b/site/blog/index.html new file mode 100644 index 00000000..5e5420e4 --- /dev/null +++ b/site/blog/index.html @@ -0,0 +1,84 @@ + + + + + +Blog — ThreeRT + + + + + + + + + + + + + + + + + + + + + +
+
+ Blog +

Notes from the metal.

+

What we build into ThreeRT, how it works, and what it measured.

+
+
+ +
+ + three.js objects on a Sony PS3, under a PocketJS overlay + + December 3, 2026 · 14 min + three.js on a Sony PS3 + A WebGL developer’s tour of the RSX: two memories, a command FIFO you write yourself, fragment uniforms that live inside the program, and how a three.js r187 scene reached it at 1920 × 1080. + Read the post → + + +
+ + + + + + diff --git a/site/blog/ps3/index.html b/site/blog/ps3/index.html new file mode 100644 index 00000000..08fd5af7 --- /dev/null +++ b/site/blog/ps3/index.html @@ -0,0 +1,485 @@ + + + + + +three.js on a Sony PS3 — ThreeRT Blog + + + + + + + + + + + + + + + + + + + + + +
+
+ Blog · December 3, 2026 +

three.js on a Sony PS3.
A WebGL developer’s tour of the RSX.

+

three.js now draws on a 2006 Sony PlayStation 3: a scene written against the three package from npm, lit with physically based materials and a planar mirror, at 1920 × 1080, with a PocketJS interface in the same frame. The PS3 has no WebGPU and no JIT, and three.js has never had a renderer for its GPU.

+
+
+ +
+ + +
+
+ A Sony PS3 frame at 1920 by 1080: a gold torus knot, PBR satellites and a mirrored floor, under a PocketJS overlay reading 20 fps, 25,990 triangles and 26 draws +
Read from the RSX’s front buffer over the network at 1920 × 1080: a TorusKnotGeometry in a MeshPhysicalMaterial, three coloured PointLights, an environment map, 260 additive embers, a planar mirror drawn with the stencil buffer, and the PocketJS overlay.
+
+ +
+

Running JavaScript on old consoles is not new, and neither is three.js outside a browser tab: desktop apps have shipped it for years, with a browser inside them. What we believe is new is three.js itself on hardware where it could not run at all: the scene code you already write, unchanged, drawn by a GPU from 2006, with a small native runtime in place of a browser.

+

This post is how we got there: what three.js needs from a machine, how the PS3 draws when you look at it from WebGL, what we built in between, the five bugs that cost us the most, and what it measured. The work is part of ThreeRT, the native runtime for three.js.

+
+ +
+ 01 +

The premise

+

three.js has always come with a browser, and it is easy to think it needs one. It does not. Its scene graph, math, geometry generators, materials, lights and cameras are plain JavaScript with no DOM in them. Two things need the browser: the renderer, which speaks WebGL or WebGPU, and the JIT that keeps the renderer’s per-frame JavaScript fast.

+
+
Until now

three.js ran where a browser ran. Outside the web you shipped one with it: Electron, a WebView. On a machine with no WebGL or WebGPU and no JIT, three.js did not run at all.

+
Now

three@0.187.0, imported as it is, builds the scene on the PS3’s Cell; a renderer we wrote draws it on the RSX at 1920 × 1080; PocketJS draws the interface into the same frame. Four demos run at 16 to 30 fps.

+
+

So we split the two. We kept everything of three.js that is plain JavaScript and replaced one thing, the renderer: once a frame, RSXRenderer walks the three.js scene and hands it to C code that draws on the RSX. The JavaScript runs on QuickJS, an interpreter with no JIT, on the Cell’s PowerPC core.

+

The console is a PlayStation 3 Slim (CECH-2500) on system software 4.81 with custom firmware, which homebrew needs. What carries over, and what does not yet:

+
keeps
the scene: Mesh, InstancedMesh, Points, Line; standard, physical, Phong, Lambert, basic and normal materials; ambient, hemisphere, directional and point lights; fog
replaces
WebGLRenderer, with RSXRenderer and native code
not yet
what lives inside three.js’s renderer: shadows, ShaderMaterial and TSL, three.js’s post-processing
+
+ +
+ 02 +

The PS3, seen from WebGL

+

If you know WebGL, you know how the PS3 rasterizes: vertex and index buffers, depth testing, fragment programs, blending. What changes is everything around them. In a browser, a driver places your memory, compiles your shaders and synchronizes with the GPU. On a PS3 there is no driver: that is your code.

+ +
+ Drawing a three.js scene, in a browser and on a PS3 +
+
+

In a browserWebGL

+
Your three.js scene
+
three.js WebGLRenderer
+
JavaScript, JIT-compiledV8 or JavaScriptCore
+
WebGL → GPU process → ANGLE
+
The OS drivercompiles GLSL, places memory, synchronizes
+
A unified-shader GPU
+
The compositor → a window
+
+
+

On a Sony PS3RSX

+
Your three.js scenethree@0.187.0, as it is
+
RSXRendererwalks the scene, packs typed arrays
+
JavaScript, interpretedQuickJS on the Cell PPU, big-endian
+
A C host writes the command FIFOPSL1GHT, packets of 32-bit words
+
Your code is the driverallocates VRAM, fences, flips
+
The RSXseparate vertex and fragment units
+
HDMI scanout, no compositor
+
+
+

the same on bothwhat we wrotethe driver’s job in a browser, ours on a PS3

+
+ +

Two memories, and you manage both

+

Memory is split in two: 256 MiB of XDR for the Cell, where QuickJS, three.js and PocketJS live, and 256 MiB of GDDR3 for the RSX. You allocate GPU memory yourself (rsxMemalign), turn CPU pointers into the offsets the RSX understands (rsxAddressToOffset), order your writes with a PowerPC barrier (eieio) and invalidate the RSX’s vertex and texture caches when you change what is in them. Two 1080p colour buffers and a depth-and-stencil buffer take about 25 MB; the rest is for meshes, textures and glyph atlases.

+ +
+ The two memories, and the command FIFO between them + + + + Cell PPU · 3.2 GHz + 256 MiB XDR · QuickJS · three.js · PocketJS + command FIFO · 2 MiB + + + + + + get · the RSX reads + put · the CPU writes + jump back to the start while the RSX is idle + DMA + + RSX · 500 MHz + 256 MiB GDDR3 + vertex and index buffers + textures, glyph atlases + fragment programs + 2 × 1080p colour · Z24S8 + +
Done words are grey, words the RSX has not reached yet are lit. The fragment programs live in GPU memory, which matters below.
+
+ +

No driver: you write the command stream

+

There is no gl.drawElements() on PS3 homebrew. The CPU and the RSX share a ring of 32-bit words, the command FIFO: every graphics call writes a method header and its arguments at put, and the RSX’s get chases it. Two things follow.

+
    +
  • You own synchronization. Overwrite a buffer the RSX has not read yet, or rewind the ring while get is behind put, and it reads garbage and locks the console. You fence with rsxFinish and an increasing reference, and present with gcmSetFlip.
  • +
  • You own the ring’s end. Write more in one frame than the segment holds without jumping back to its start (rsxSetJumpCommand) and you run off its end. An InstancedMesh taught us this; see bug 5.
  • +
+ +

Two shader units, and fragment constants live inside the program

+

The RSX comes from NVIDIA’s G70, the GeForce 7800 generation, and PSL1GHT drives it with NV40-class registers and assembly. It is the last generation before unified shaders: vertex programs (!!VP2.0) and fragment programs (!!FP2.0) run on different units with different rules. Vertex programs read constants from a bank of vec4 registers, c[…], loaded through the FIFO. Fragment programs have no such bank.

+

A fragment “uniform” is a 16-byte slot in the program’s own machine code. The assembler leaves the slot and records where it is. To set it, you write the value into the program in GPU memory, with a DMA write ordered with your other commands (rsxInlineTransfer), and every 32-bit float has its two 16-bit halves swapped, because that is the order in which the fragment unit fetches words. Then you point the RSX at the program again so it does not run a stale copy.

+ +
+ Setting uTint = (1.0, 0.85, 0.4, 1.0) in a fragment program +
+
+
+0x00MOV R1, c[0]9e011700 c8011c9d c8000001 c8003fe1
+
+0x10slot for uTint00003f80 999a3f59 cccd3ecc 00003f80
+
+0x20MULR o[COLR], f[COL0], R102011e81 c8011c9d c8000001 c8003fe1
+
+0x30END…
+ the program, in GPU memory +
+
    +
  1. Swap halves1.0 = 0x3f800000 → 0x00003f800.85 = 0x3f59999a → 0x999a3f59
  2. +
  3. Write it into the slotrsxInlineTransfer(ctx, fp_offset + 0x10, …)
  4. +
  5. Point the RSX at the program againrsxLoadFragmentProgramLocation(…)
  6. +
+
+
The instruction words are illustrative; the slot’s bytes are the real swapped values. In a browser the same thing is gl.uniform4f(loc, 1, 0.85, 0.4, 1).
+
+ +

Big-endian on both sides

+

The Cell is big-endian, and so is the RSX. QuickJS keeps a Float32Array in the CPU’s byte order, which is the order the RSX reads vertices and indices in. So when three.js fills a BufferGeometry or an InstancedMesh’s matrices, our bridge takes the array’s memory and copies it to the GPU as it is: no per-element conversion, no byte swapping.

+
+ +
+ 03 +

One triangle, five stages

+

The same coloured triangle, drawn both ways. Every design choice in the three.js renderer comes out of these five differences.

+ +

1 · Upload the vertices

+
+
WebGL
// The driver places and caches it.
+const vbo = gl.createBuffer();
+gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
+gl.bufferData(gl.ARRAY_BUFFER, verts,
+              gl.STATIC_DRAW);
+
PS3
// Aligned GPU memory, a barrier, an offset, a cache flush.
+TriVert *vb = rsxMemalign(64, 3 * sizeof(TriVert));
+memcpy(vb, triangle, 3 * sizeof(TriVert));
+__asm__ volatile("eieio" ::: "memory");
+u32 vb_off; rsxAddressToOffset(vb, &vb_off);
+rsxInvalidateVertexCache(ctx);
+
+ +

2 · Load the shaders

+

GLSL compiles on the user’s machine. RSX programs are assembled before the build (cgcomp -a); the vertex program is sent through the FIFO, and the fragment program is copied into GPU memory, because the RSX fetches fragment instructions from there.

+
+
WebGL
// GLSL, compiled at run time.
+gl_Position = uMVP * vec4(aPos, 1.0);
+vColor = aColor;
+// …
+gl_FragColor = vColor * uTint;
+
PS3
# !!VP2.0: c[0..3] are the rows of uMVP
+DP4 R0.x, v[0], c[0];   DP4 R0.y, v[0], c[1];
+DP4 R0.z, v[0], c[2];   DP4 R0.w, v[0], c[3];
+MOV o[HPOS], R0;        MOV o[COL0], v[3];
+# !!FP2.0: c[0] is the uTint slot
+MOV R1, c[0];
+MULR o[COLR], f[COL0], R1;
+
+ +

3 · Set the uniforms

+

Here the two worlds part. A vertex constant is a block load through the FIFO, cheap enough for every draw. A fragment constant is a write into the program and a reload of it.

+
+
WebGL
gl.uniformMatrix4fv(locMVP, false, mvp);
+gl.uniform4f(locTint, 1.0, 0.85, 0.4, 1.0);
+
PS3
// Vertex: four rows into c[0..3].
+rsxLoadVertexProgramParameterBlock(ctx, 0, 4, mvp_rows);
+// Fragment: into the program itself, halves swapped.
+for (u32 i = 0; i < tab->num; i++)
+  rsxInlineTransfer(ctx, fp_off + tab->offset[i],
+                    swapped, 4, GCM_LOCATION_RSX);
+rsxLoadFragmentProgramLocation(ctx, fp, fp_off,
+                               GCM_LOCATION_RSX);
+
+ +

4 · Draw

+

WebGL’s clip space has +Y up and the screen comes out right. The RSX scans out top-down with depth from 0 to 1, so a viewport with a negative Y scale maps three.js’s clip space onto it; attributes are bound by GPU offset.

+
+
WebGL
gl.viewport(0, 0, 1920, 1080);
+gl.vertexAttribPointer(0, 3, gl.FLOAT,
+                       false, 28, 0);
+gl.drawArrays(gl.TRIANGLES, 0, 3);
+
PS3
f32 scale[4]  = { 960, -540, 0.5f, 0 };
+f32 offset[4] = { 960,  540, 0.5f, 0 };
+rsxSetViewport(ctx, 0, 0, 1920, 1080, 0, 1, scale, offset);
+rsxBindVertexArrayAttrib(ctx, GCM_VERTEX_ATTRIB_POS, 0,
+  vb_off, sizeof(TriVert), 3, GCM_VERTEX_DATA_TYPE_F32,
+  GCM_LOCATION_RSX);
+rsxDrawVertexArray(ctx, GCM_TYPE_TRIANGLES, 0, 3);
+
+ +

5 · Present

+

In a browser you return from requestAnimationFrame. On a PS3 nothing reaches the TV until you flush the FIFO, fence the RSX, rewind the ring, wait for the last flip and queue the next.

+
+
WebGL
requestAnimationFrame(loop);
+
PS3
rsxFlushBuffer(ctx);
+rsxFinish(ctx, ++ref);              // the RSX is done
+rsxSetJumpCommand(ctx, begin_off);  // rewind the ring
+while (gcmGetFlipStatus() != 0) usleep(200);
+gcmResetFlipStatus();
+while (gcmSetFlip(ctx, fb) != 0) usleep(200);
+rsxFlushBuffer(ctx);
+gcmSetWaitFlip(ctx);
+fb ^= 1;
+
+
+ +
+ 04 +

From three.js to the RSX

+

The showcase starts with import * as THREE from "three". RSXRenderer (platforms/ps3/three-rsx-renderer.ts) walks that scene and talks to the C engine (platforms/ps3/rsx3d.c) through one global object, globalThis.__rsx3d, whose arguments are typed arrays.

+ +
+ One frame, from the three.js scene to the TV +
+
QuickJS · Cell PPU +
three.js sceneScene · Mesh · InstancedMesh · Points · lights
→
RSXRendererwalk · sort · pack Float32Array
+
PocketJSSolid JSX + Tailwind, 3× density
+
C host · PSL1GHT +
__rsx3dtyped arrays, read where they are
→
rsx3dGPU memory pools · constants · mirror
→
rsx_driverZ24S8 surface · FIFO rewind · flip
+
RSX · 1920 × 1080 +
Pass 1 · 3Dsky · mirror · PBR · points
→
Pass 2 · UIover the 3D, no clear
→
Front bufferto HDMI, and over TCP :8623
+
+
three.js and PocketJS share the CPU; one surface takes both passes, so there is no offscreen target and no extra full-screen copy.
+
+ +

Scene-wide values once a pass, per-object values per draw

+

A fragment constant costs a write into the program and a reload, so the renderer splits uniforms along that line. Values that are the same for the whole scene (the camera position and exposure, the directional light, three point lights, the hemisphere light, fog) are written into the PBR fragment program once a pass. Everything per object (its matrices, colour, emissive, roughness, metalness, UV transform) goes into vertex constants and reaches the fragment unit through interpolators. No fragment program is reloaded per mesh.

+ +

One call for an InstancedMesh, and what it still costs

+

QuickJS has no JIT, and calling into C once per instance with loose numbers would spend the frame on an in-order core. So for an InstancedMesh the renderer passes three.js’s own instanceMatrix.array and instanceColor.array to C in one call; C loads the shared material constants once and loops over the instances on the PPU.

+

That keeps JavaScript out of the loop, but the RSX has no hardware instancing: every instance is still a draw with its own constants. With 196 instances, writing those commands takes 28.9 ms of the PPU’s time a frame, and that demo is the slowest, at 16 fps. The Cell has six SPUs doing nothing; this loop is the first thing to move onto them.

+ +

Two passes into one frame

+

rsx_driver.c binds one 1920 × 1080 colour surface with a 24-bit depth and 8-bit stencil buffer and calls the scene first. Pass 1 clears colour, depth and stencil and draws the 3D scene. Pass 2 clears nothing, resets the depth, stencil and cull state, and draws the PocketJS interface over it with alpha blending. PocketJS apps that draw no 3D do not change.

+
+ +
+ 05 +

Shaders for a 2006 GPU

+

What makes a 2006 GPU look current is less how many triangles it draws than how materials answer light. Three things do most of that here.

+
    +
  • Per-pixel PBR. Metalness and roughness, Schlick’s Fresnel without a POW (x = 1 − N·V, then x²·x²·x), a directional light with a roughness-scaled Blinn-Phong lobe and three point lights per pixel, then the ACES filmic curve, so highlights roll off instead of clipping.
  • +
  • An environment map without trigonometry. A 256 × 128 studio panorama (a warm softbox overhead, a cool strip at the side, a ring at the zenith) sampled along the reflection vector with a projection that needs no atan2: t = R.x / (|R.x| + |R.z|), u = R.z < 0 ? 0.75 − 0.25t : 0.25 + 0.25t, v = 0.5 − 0.48 R.y. The two halves meet at u = 0.5 and wrap at 0 and 1.
  • +
  • A planar mirror with the stencil buffer. Draw the floor into the stencil only; draw the reflectable meshes flipped below it where the stencil is set, with the winding reversed; clear depth; draw the floor over them, partly transparent.
  • +
+
+ +
+ 06 +

Five bugs

+

The toolchain ran on an Apple-silicon Mac (PSL1GHT in a Docker image, Rust for powerpc64), and every one of these happened on the console. If you write for the RSX, they may save you some days.

+ +

1 · Every fragment uniform was zero

+

The first three.js frame showed a sharp PocketJS overlay over a black screen. Disassembling PSL1GHT’s prebuilt rsxSetFragmentProgramParameter in librsx.a showed the value argument copied into a register that is overwritten before it is used, and a zeroed 16-byte stack buffer passed to rsxInlineTransfer instead: every fragment uniform, exposure and every light included, was uploaded as zeros. Our reading is that GCC 13 optimized the copy away under strict aliasing. A twelve-line replacement that copies with memcpy and calls rsxInlineTransfer itself fixed it.

+
  48: mr   r28, r6        # r28 = the value
+  d0: mr   r28, r3        # overwritten before it is read
+ 104: addi r5, r1, 112    # the zeroed stack buffer
+ 110: bl   rsxInlineTransfer
+ +

2 · Every vertex landed on one point

+

With uniforms fixed the sky appeared, and no triangle did. The vertex assembler (cgcomp -a -v) ignores write masks on output registers: four DP4 o[HPOS].x/.y/.z/.w each assembled to a full .xyzw write, so every vertex became (w, w, w, w). Computing into R0.x to R0.w and ending with MOV o[HPOS], R0 fixed it.

+ +

3 · The fragment assembler drops what it does not know

+

cgcomp -a -f, used because NVIDIA’s Cg compiler does not run on ARM64 Linux, turned SUB into a 16-byte no-op (write ADD R0, R1, -R2), dropped ABS (write MOV R0, |R1|), read inline literals such as {14.0}.x as R0 (put every number in a named constant), and crashed on a blank line.

+ +

4 · The camera that never moved

+

camera.updateMatrixWorld() does not update camera.matrixWorldInverse; WebGLRenderer.render() does, with matrixWorldInverse.copy(matrixWorld).invert(). A custom renderer that skips that line draws from the origin, looking down −Z, wherever the camera is.

+ +

5 · Off the end of the ring

+

The instanced demo with 400 instances locked the RSX on its first frame. Each instance writes about 58 words (its constants and a draw), and 400 of them are about 92 KB, past the end of the FIFO segment. Two fixes: the driver rewinds the ring after every frame, and rsx3d.c checks for space before a batch and rewinds in the middle of a frame when it must. The demo also went to 196 instances (14 × 14), and the point lights’ POW became repeated squaring, which freed three registers in the PBR program.

+
+ +
+ 07 +

What it measured

+

Each frame below was read at 1920 × 1080 from the RSX’s front buffer over the DevShell, a TCP service on port 8623 that also reloads the app’s bundle in place and injects controller input, so we never went back to the console’s menu while working.

+
+
The showroom: a gold torus knot over a mirrored floor
Showroom 25,990 triangles · 26 draws · planar mirror · 20 fps
+
The instanced wave: 196 metallic pillars in a grid
Instanced wave 196 instances · 199 draws · 28.9 ms to write them · 16 fps
+
A planet with rings in front of a spiral galaxy of 2,400 points
Galaxy 5,678 triangles · 2,400 point sprites · 7 draws · 30 fps
+
Twenty spheres from smooth to rough and from dielectric to metal
Material grid 58,886 triangles · 43 draws · mirror · 26 fps
+
+

None of them reaches 60. In three of the four, writing the 3D commands takes 0.1 ms, so most of the frame goes somewhere we have not measured yet: QuickJS walking the scene on the PPU, the RSX shading two million pixels of PBR (twice, where there is a mirror), or waiting for vsync. That profile is the next piece of work, and then the SPUs.

+

With a DualShock 3: L1 and R1 change the scene, the sticks orbit and zoom, △ shows wireframe, ○ turns the mirror off and on, □ stops the orbit, SELECT hides the overlay.

+
+ +
+ 08 +

What it means for ThreeRT

+

ThreeRT is a native runtime for three.js: no browser between your scene and the GPU. How much of three.js stays depends on the machine. On macOS and Linux, webgpu keeps all of it, three.js and its own WebGPURenderer, and replaces only the browser: a 9.9 MB app where Electron takes 445 MB. On GPUs with ray-tracing hardware, path replaces the renderer with a path tracer at 60 fps. The PS3 is the third case. It has no WebGPU and no JIT, so three.js keeps its scene graph and a native renderer draws it.

+

The PS3 port is experimental, and it is built in PocketJS (platforms/ps3), not by ThreeRT’s tools. What it shows is how little a three.js scene needs from a machine once the browser is gone. How the three ways differ is in RENDERING-METHODS.md.

+ +
+
+
+ + + + + + diff --git a/site/brand/card.jpg b/site/brand/card.jpg index 530f9b07..92d99e85 100644 Binary files a/site/brand/card.jpg and b/site/brand/card.jpg differ diff --git a/site/docs/index.html b/site/docs/index.html index 117e805a..4feeaffb 100644 --- a/site/docs/index.html +++ b/site/docs/index.html @@ -5,6 +5,17 @@ ThreeRT Docs — getting started + + + + + + + + + + + - -