Blog · December 3, 2026

Running Vanilla Three.js r187 at 1080p on a 2006 PlayStation 3

A WebGL developer’s tour of the PS3 RSX GPU, raw NV40 shader assembly, hardware-stenciled planar reflections, and why ThreeRT is a runtime—not just a renderer.

If you write WebGL or Three.js for fun, you live inside a remarkably polite abstraction. You call new THREE.TorusKnotGeometry(), hand it a MeshPhysicalMaterial, drop three PointLights into a Scene, and call renderer.render(scene, camera). Beneath that line sits an entire civilization of software: a JIT-compiled JavaScript engine, a browser compositor, ANGLE, OpenGL or Metal or Vulkan, and a multi-hundred-megabyte GPU driver quietly managing memory, compiling GLSL, and hiding hardware weirdness.

Now take all of that away.

No Chrome. No Electron. No WebGL, no OpenGL, no Vulkan, no Metal, no wgpu, and no JavaScript JIT. Just a 2006 PlayStation 3—a 3.2 GHz big-endian PowerPC Cell with 256 MiB of main memory, paired with NVIDIA’s RSX “Reality Synthesizer” and its own 256 MiB of GDDR3—running vanilla three@0.187.0 (import * as THREE from "three") at native 1920 × 1080, with a PocketJS (SolidJS + Tailwind) HUD composited on top at 3× density.

A PlayStation 3 frame at 1920 by 1080: a gold torus knot, PBR satellites and a mirrored floor, under a PocketJS HUD reading 20 fps, 25,990 triangles and 26 draws
Captured straight from a PlayStation 3 Slim’s RSX front buffer over TCP: a liquid-gold TorusKnotGeometry, three orbiting coloured PointLights, studio reflections, 260 additive embers, a hardware-stenciled real-time mirror floor, and a translucent SolidJS HUD—all driven by real three@0.187.0.

This post is the engineering story behind that screenshot: what makes the PS3’s graphics architecture genuinely strange if you come from WebGL, how we bridged unmodified Three.js r187 onto raw RSX command buffers and hand-written NV40 assembly shaders, five wild bugs we caught by disassembling the console toolchain, and what this means for ThreeRT—the native runtime for Three.js.

01

What makes the PS3 GPU weird (through WebGL eyes)

If you know WebGLRenderingContext, you already have the right mental model for rasterization: vertex buffers, index buffers, depth testing, fragment shaders and blending all exist on the PS3. What changes is everything around them.

Split memory, zero driver hand-holding

In WebGL, gl.bufferData() and gl.texImage2D() hand bytes to a driver that decides where they live, migrates them on demand, and cleans up after you. On a PlayStation 3, memory is physically split in two:

  • 256 MiB of XDR for the Cell, where QuickJS, Three.js and PocketJS live
  • 256 MiB of GDDR3 for the RSX (500 MHz core, 24 pixel pipelines, 8 vertex units)

You allocate VRAM yourself with rsxMemalign(64, bytes), translate raw pointers into the offsets the RSX understands (rsxAddressToOffset), order your writes with a PowerPC barrier (eieio), and explicitly invalidate the vertex and texture caches whenever you upload new data. Two 1920 × 1080 A8R8G8B8 colour buffers cost about 16.6 MB; a full 1080p Z24S8 depth-and-stencil buffer costs another 8.3 MB. That still leaves more than 200 MiB of VRAM 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
Words the RSX has already read are grey; words it has not reached yet are lit. Note where the fragment programs live—in GPU memory. That matters in a minute.

No OpenGL—you speak the raw command FIFO

There is no gl.drawElements() driver layer in PS3 homebrew (PSL1GHT, the open-source take on libgcm). Instead, the CPU and GPU talk through a DMA ring buffer—the command FIFO—in shared memory. Every “graphics call” simply writes 32-bit method headers and payload words at ctx->current, then rings the doorbell (rsxFlushBuffer) so the RSX’s get pointer chases your put pointer.

That has two huge consequences for a WebGL developer:

  1. You own synchronization. Overwrite a vertex buffer, or rewind the ring, while the RSX’s get is still behind your put, and it reads garbage and hard-locks the console. You fence with rsxFinish(ctx, ++ref) and pace display flips with gcmSetFlip and gcmSetWaitFlip.
  2. You own the ring’s end. Push too many commands in one frame without jumping back to the start with rsxSetJumpCommand, and you run straight off the end of the segment. (How THREE.InstancedMesh taught us this the hard way is bug 5.)

Pre-unified shaders—and the wildest uniform mechanism you’ve ever seen

The RSX descends from NVIDIA’s G70, the GeForce 7800 GTX generation, and PSL1GHT drives it with NV40-class registers and assembly. That is the last generation before unified shader cores: vertex programs (!!VP2.0) and fragment programs (!!FP2.0) run on completely different processors with completely different rules.

WebGL (GLSL)RSX vertex !!VP2.0RSX fragment !!FP2.0
Uniform storageuniforms, UBOsa bank of vec4 registers, c[…]none!
Setting onegl.uniform4f(…)a block load through the FIFOpatched into the program’s microcode, in VRAM
Constants per instructionas many as you likeat most one c[k]at most one c[k]
Interpolatorsvaryingso[COL0..1], o[TEX0..7]f[COL0..1], f[TEX0..7]

Read that second row again. The RSX fragment processor has no uniform registers.

When you declare a fragment uniform like uCamPos or uDirCol, the assembler (cgcomp) leaves a 16-byte hole right inside the fragment program’s machine code and records its byte offset in a constant table. Setting a fragment uniform literally means issuing a GPU-ordered DMA write (rsxInlineTransfer) that self-modifies the fragment program in VRAM—with every 32-bit float halfword-swapped, (bits >> 16) | (bits << 16), because that is the order the fragment unit fetches words in—and then pointing the RSX at the program again so it doesn’t 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. Write it into the slotrsxInlineTransfer(ctx, fp_offset + 0x10, …)
  3. Point the RSX at the program againrsxLoadFragmentProgramLocation(…)
The instruction words are illustrative; the slot’s bytes are the real swapped values. In a browser, all of this is gl.uniform4f(loc, 1, 0.85, 0.4, 1).

The big-endian silver lining

The Cell is big-endian PowerPC. In WebGL on x86 or ARM you almost never think about byte order. On the PS3, QuickJS stores Float32Array, Uint16Array and Uint32Array in the CPU’s native order—which is also the order the RSX reads vertices and indices in.

So when Three.js builds a BufferGeometry or updates InstancedMesh.instanceMatrix.array, our C bridge grabs the array’s memory with JS_GetTypedArrayBuffer and copies it straight into VRAM, with no per-element boxing and no byte swapping.

Two completely different worlds

Before looking at code, here is the gap between drawing in a browser and drawing on PS3 bare metal:

Drawing a Three.js scene, in a browser and on a PS3

In a browserWebGL · managed and unified

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 GPUshared register file, uniform buffers
The compositor → a window

On a PlayStation 3RSX · explicit and pre-unified

Your Three.js scenethree@0.187.0, as it is
RSXRendererwalks the scene, packs typed arrays
JavaScript, interpretedQuickJS on the big-endian Cell PPU
A thin C bridge writes the 2 MiB FIFOPSL1GHT, packets of 32-bit words
Your code is the driverallocates VRAM, fences, flips
The RSXVP2.0 → FP2.0, constants patched into VRAM
HDMI scanout at 1920 × 1080, no compositor

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

Notice how many layers disappear on the right—and how much responsibility moves straight into your own C code.

02

Side by side: drawing one triangle in WebGL vs. the RSX

Every graphics programmer learns by drawing a single coloured triangle. Walking through the five stages of that one triangle side by side makes the PS3 click—and explains every optimization we had to build for Three.js later.

Ours has a red, a green and a blue corner, so you can follow it. At each stage it is something different—84 bytes, three vertices, two uniforms, 259,200 pixels, a frame on the TV—and the GPU math on the way is the same on both machines. What differs is who carries it from one stage to the next.

One RGB triangle through the five stages
1 · Upload
x y zr g b a
84 bytes
WebGLbufferData; the driver picks the memory
PS3 RSXyou place it in GDDR3, fence, flush
2 · Shaders
3 vertices
WebGLGLSL, compiled on the user’s machine
PS3 RSXassembled offline; the fragment code copied into VRAM
3 · Uniforms
×= uMVP · uTint
2 uniforms
WebGLone call, either stage
PS3 RSXvertex: registers; fragment: a patch in VRAM
4 · Draw
1920 × 1080
259,200 pixels
WebGL+Y up, by default
PS3 RSXyour surface, your viewport, Y flipped
5 · Present
1 frame on the TV
WebGLreturn from requestAnimationFrame
PS3 RSXfence, rewind the FIFO, flip

the driver’s job in a browser, ours on a PS3

The rasterizer, the interpolation and the pixels are the same on both: the RSX is a GPU like any other once a draw starts. Everything that gets the triangle to that point, and from there to the TV, is the driver’s in a browser and your C code’s on a PS3. The five stages below zoom in one at a time.

Stage 1 · Uploading vertex data

In WebGL you hand a Float32Array to the driver and forget where it lives. On the RSX you carve aligned bytes out of GDDR3 yourself, enforce a PowerPC memory barrier, convert the CPU pointer into an RSX offset, and flush the GPU’s vertex cache:

Stage 1 · The triangle as 84 bytes, and where they go
WebGL
Float32Arrayin the JS heap; little-endian on x86 and ARM, so 0.5 is 00 00 00 3f
→
gl.bufferDatahands the bytes to the driver
→
SomewhereVRAM or system memory: the driver decides, and may move it later
PS3 RSX
Float32Arrayin XDR; big-endian, so 0.5 is 3f 00 00 00
→
memcpy, eieiointo rsxMemalign(64, 84)
→
GDDR3, at vb_offan offset the RSX reads, not a pointer
→
Cache flushedrsxInvalidateVertexCache
Seven floats a vertex, a position and a colour, so the vertices are 28 bytes apart: the stride both APIs are given in stage 4. The hex is big-endian, the order the Cell stores the floats in and the RSX reads them in, so the bytes cross into VRAM exactly as they are.
WebGL
// The driver allocates, aligns,
// migrates and caches it for you.
const vbo = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
gl.bufferData(gl.ARRAY_BUFFER, verts,
              gl.STATIC_DRAW);
PS3 RSX
// Explicit VRAM, a barrier, an offset, a cache flush.
TriVert *vb = rsxMemalign(64, 3 * sizeof(TriVert));
memcpy(vb, triangle, 3 * sizeof(TriVert));
__asm__ volatile("eieio" ::: "memory"); // reach GDDR3
u32 vb_off;
rsxAddressToOffset(vb, &vb_off);  // offsets, never pointers
rsxInvalidateVertexCache(ctx);     // old vertices are stale

Stage 2 · Writing and loading shaders

In WebGL, GLSL strings compile on the user’s machine at run time. On the RSX, shaders are assembled offline into separate !!VP2.0 and !!FP2.0 microcode (cgcomp -a). Vertex microcode goes inline over the FIFO, but fragment microcode has to be copied into 64-byte-aligned VRAM, because the RSX fetches pixel instructions straight from GDDR3:

Stage 2 · Three vertices, and the processors that run the programs
(0, 0.5)(−0.5, −0.5)(0.5, −0.5) +Y+X clip space, w = 1
WebGL
GLSL sourcestrings, shipped with the page
→
The driver compileson the user’s machine, at run time
→
One pool of coresvertices and pixels alike
RSX vertex
!!VP2.0cgcomp, offline
→
Microcodesent inline, through the FIFO
→
8 vertex unitsa vertex each
RSX fragment
!!FP2.0cgcomp, offline
→
Microcode, in VRAM64-byte aligned, at fp_off
→
24 pixel pipelinesfetch it from GDDR3
uMVP is the identity here, so clip space is just the positions. The vertex program sees three points and nothing between them: no pixel exists yet. The RSX runs the two programs on different processors, loaded two different ways; a unified GPU runs both on one pool of cores.
WebGL
// GLSL, compiled at run time.
gl_Position = uMVP * vec4(aPos, 1.0);
vColor = aColor;
// …
gl_FragColor = vColor * uTint;
PS3 RSX
# !!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: uTint is a 16-byte hole in the ucode
MOV R1, c[0];
MULR o[COLR], f[COL0], R1;

// C: the fragment program goes into VRAM
void *fp_vram = rsxMemalign(64, fp_size);
memcpy(fp_vram, fp_src, fp_size);
rsxAddressToOffset(fp_vram, &fp_off);

Stage 3 · Updating uniforms (the biggest mental shift)

In WebGL, vertex and fragment uniforms look identical. On the RSX they are two completely different hardware mechanisms:

Stage 3 · Two uniforms, kept in two different places
WebGL
uniformMatrix4fv, uniform4fthe same kind of call for either stage
→
Uniform storagethe driver’s; both programs read it the same way
RSX vertex
uMVP, as rowsone block load through the FIFO
→
Constant registersc[0]1 0 0 0c[1]0 1 0 0c[2]0 0 1 0c[3]0 0 0 1
RSX fragment
uTint, halves swappedrsxInlineTransfer into the program, then point the RSX at it again
→
The program itself, in GDDR3+0x00MOV R1, c[0]+0x1000003f80 999a3f59 cccd3ecc 00003f80+0x20MULR o[COLR], f[COL0], R1
The tint keeps red at 1 and takes green to 0.85 and blue to 0.4: the triangle on the right is what the fragment program writes. In WebGL both uniforms are one call each. On the RSX, uMVP becomes four registers loaded through the FIFO, and uTint becomes sixteen bytes in the middle of the fragment program, rewritten in VRAM whenever it changes.
WebGL
// Symmetric across stages.
gl.useProgram(program);
gl.uniformMatrix4fv(locMVP, false, mvp);
gl.uniform4f(locTint, 1.0, 0.85, 0.4, 1.0);
PS3 RSX
// 1. Vertex: a FIFO block load into c[0..3]
//    (Three.js is column-major; DP4 wants rows)
rsxLoadVertexProgramParameterBlock(ctx, 0, 4, mvp_rows);

// 2. Fragment: self-modify the program in VRAM,
//    each float's 16-bit halves swapped
for (u32 i = 0; i < tab->num; i++)
  rsxInlineTransfer(ctx, fp_off + tab->offset[i],
                    swapped, 4, GCM_LOCATION_RSX);
// Point the RSX at the program again
rsxLoadFragmentProgramLocation(ctx, fp, fp_off,
                               GCM_LOCATION_RSX);

Stage 4 · Binding attributes, viewport and the draw

In WebGL, OpenGL’s convention (+Y up, depth from −1 to 1) is automatic. On the RSX you bind the colour + Z24S8 surface yourself, set a negative-Y viewport scale so Three.js’s +Y-up clip space lands right side up on the PS3’s top-down scanout, bind attributes by VRAM offset, and emit the draw packet into the FIFO:

Stage 4 · From three vertices to 259,200 pixels
+Y+X clip space
The viewport x = 960 · xndc + 960 y = −540 · yndc + 540

Upright. Clip space’s +Y is up and the TV’s row 0 is its top, so the scale is negative.

↓ RSX row 0: the top of the TV1920 × 1080
(960, 270)(480, 810)(1440, 810)
↑ WebGL row 0: the bottoma square is 40 × 40 pixels
pixel
(980, 620) on the TV: column 980, row 620 from the top
raster
weights 0.351 · 0.303 · 0.346 → vColor (0.351, 0.303, 0.346)
fragment
× uTint = (0.351, 0.258, 0.138) → 8 bits: 59 42 23
WebGL
row 459 from the bottom · readPixels(980, 459, …) → 59 42 23 ff R G B A
PS3 RSX
row 620 from the top · fb + 620 × 7680 + 980 × 4 = fb + 4,765,520 → ff 59 42 23 A R G B, one big-endian word
A square is lit where the pixel at its centre is inside the triangle, in the colour that pixel gets. Point at one (or tap it, or use the arrow keys) to follow it: the rasterizer weighs the three vertex colours by how close the pixel is to each corner (GCM_SHADE_MODEL_SMOOTH; a varying in GLSL), the fragment program multiplies by uTint, and the result is 32 bits—which WebGL keeps behind readPixels, and the RSX keeps at an address you can compute: 7680 bytes is a row of the surface. Flip the viewport’s sign to see why the negative scale is there.
WebGL
gl.viewport(0, 0, 1920, 1080);
gl.clear(gl.COLOR_BUFFER_BIT |
         gl.DEPTH_BUFFER_BIT);
// xyz, then rgba 12 bytes in
gl.vertexAttribPointer(0, 3, gl.FLOAT,
                       false, 28, 0);
gl.vertexAttribPointer(1, 4, gl.FLOAT,
                       false, 28, 12);
gl.drawArrays(gl.TRIANGLES, 0, 3);
PS3 RSX
rsxSetSurface(ctx, &surface);  // A8R8G8B8 + Z24S8
rsxClearSurface(ctx, GCM_CLEAR_R | GCM_CLEAR_G |
  GCM_CLEAR_B | GCM_CLEAR_A | GCM_CLEAR_Z | GCM_CLEAR_S);
// NDC (+Y up, z in [-1, 1]) -> top-down, z in [0, 1]
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);
// The colour, 12 bytes in: v[3] in the vertex program
rsxBindVertexArrayAttrib(ctx, GCM_VERTEX_ATTRIB_COLOR0, 0,
  vb_off + 12, sizeof(TriVert), 4, GCM_VERTEX_DATA_TYPE_F32,
  GCM_LOCATION_RSX);
rsxDrawVertexArray(ctx, GCM_TYPE_TRIANGLES, 0, 3);

Stage 5 · Presenting the frame (sync, rewind, flip)

In WebGL, presentation is invisible—you just return from requestAnimationFrame. On the RSX, nothing reaches your TV until you flush the FIFO, fence the GPU, rewind the ring so it never overflows, wait for the previous flip, and queue the next scanout buffer:

Stage 5 · From finished pixels to the TV
WebGL
Your callback returns
canvasdrawn
frontthe browser’s
→
The browser compositesthe canvas into the page, on its own schedule
→
At a vsync it picks
windowon screen
PS3 RSX
Frame N
fb 0on HDMI
fb 1being drawn
→
Flipflush · rsxFinish · rewind the FIFO · wait for the last flip · gcmSetFlip(fb 1)
→
At vsync: frame N + 1
fb 0drawn next
fb 1on HDMI
Each colour buffer is 1920 × 1080 × 4 = 8,294,400 bytes of GDDR3, at an offset HDMI was given once, at boot (gcmSetDisplayBuffer). The RSX never draws into the buffer HDMI is reading: the flip swaps the two at vsync, and fb ^= 1 sends the next frame to the other one. A browser keeps a front buffer too; it is just never yours.
WebGL
// The browser flushes, waits for
// vsync and composites for you.
function loop() {
  drawTriangle();
  requestAnimationFrame(loop);
}
PS3 RSX
rsxFlushBuffer(ctx);
rsxFinish(ctx, ++ref);              // the RSX is done
rsxSetJumpCommand(ctx, begin_off);  // rewind the ring
ctx->current = ctx->begin;
while (gcmGetFlipStatus() != 0) usleep(200);
gcmResetFlipStatus();
while (gcmSetFlip(ctx, fb) != 0) usleep(200);
rsxFlushBuffer(ctx);
gcmSetWaitFlip(ctx);
fb ^= 1;                            // swap front and back

Once you’ve seen those five stages side by side, nothing about PS3 graphics feels mysterious anymore—and every design decision in our Three.js adapter follows straight from them.

03

Bridging vanilla Three.js r187 to the RSX + PocketJS

Here’s the secret that makes real three@0.187.0 possible on a 2006 console: Three.js’s scene graph, math library, geometry generators, materials, lights and cameras are plain ES-module JavaScript with no DOM dependencies. Only the renderer touches a <canvas>.

So we didn’t fork Three.js, and we didn’t write a toy “Three-like” clone. The showcase app literally starts with:

import * as THREE from "three";

…and our own RSXRenderer (platforms/ps3/three-rsx-renderer.ts) walks the real THREE.Scene and drives a native C engine (platforms/ps3/rsx3d.c) through one thin typed-array bridge, globalThis.__rsx3d:

One frame, from the Three.js scene to the TV
QuickJS · Cell PPU
Three.js r187Scene · Mesh · InstancedMesh · Points · lights
→
RSXRendererwalk · sort · pack Float32Array
+
PocketJSSolidJS + Tailwind, 3× density
C host · PSL1GHT
__rsx3dtyped arrays, read where they are
→
rsx3dVRAM pools · constants · mirror
→
rsx_driverZ24S8 surface · FIFO rewind · flip
RSX · 1920 × 1080
Pass 1 · 3Dsky · stencil mirror · PBR · points
→
Pass 2 · UIalpha-blended over 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.

Vanilla means the package is untouched—what we replace is the renderer. What carries over, and what doesn’t 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 own renderer: shadows, ShaderMaterial and TSL, its post-processing

Design trick #1: a zero-stall uniform split

Patching fragment microcode stalls the fragment pipeline if you do it per mesh, so we split uniforms strictly along the NV40’s hardware grain:

  • Scene-wide values—camera position and exposure, the directional key light, three coloured point lights, hemisphere sky and ground, exponential fog—are patched into pbr3d.fp once per pass.
  • Per-draw and per-instance values—MVP, model matrix, the inverse-transpose normal matrix, base colour, emissive, roughness / metalness / environment intensity, UV repeat and offset—go into vertex constants and reach the fragment program through the interpolators o[COL0] and o[TEX0..4].

Result: no fragment program reloads per mesh, even across hundreds of draws.

Design trick #2: one native call per InstancedMesh

QuickJS is an interpreter—no V8, no JSC JIT. Calling into C 200 times a frame with loose floats would burn precious cycles on an in-order PowerPC core. So for a THREE.InstancedMesh, RSXRenderer hands Three.js’s own instanceMatrix.array and instanceColor.array to C in one native call:

native.drawInstanced(geoId, texId, mats, cols, im.count, this.instBuf, flags);

Inside rsx3d.c, C uploads the shared material constants once, then loops on the 3.2 GHz PPU computing MVP = VP × M and the normal matrix for each instance, uploading its constants and issuing rsxDrawIndexArray back to back—no vertex buffer or texture rebinds.

The honest cost: the RSX has no hardware instancing, so every instance is still its own draw. With 196 instances, writing those commands takes 28.9 ms of PPU time a frame, and that demo is our slowest at 16 fps. The Cell’s SPUs are the obvious next home for that loop.

Design trick #3: 3D and the PocketJS UI in one backbuffer

Rather than rendering the 3D scene into an offscreen target and blitting it, rsx_driver.c calls the scene right after binding the 1920 × 1080 A8R8G8B8 + Z24S8 surface:

  1. Pass 1 (3D): clear colour, depth and stencil, set the negative-Y viewport so Three.js’s right-handed clip space (+Y up, z from −1 to 1) works unmodified, and draw the scene.
  2. Pass 2 (PocketJS UI): skip the colour clear, reset depth, stencil, culling and polygon mode, switch to ui.vp / ui.fp with SRC_ALPHA, ONE_MINUS_SRC_ALPHA, and paint the SolidJS + Tailwind HUD straight over the 3D pixels at crisp 3× density.

No extra full-screen pass, no extra render targets—and existing 2D-only PocketJS apps don’t change at all when no 3D scene is submitted.

04

Pushing NV40 shaders: PBR, trig-free IBL and stenciled reflections

On a 2006 console, the trick to making 3D look genuinely modern isn’t brute-forcing polygon counts—it’s material response: specular sheen, Fresnel rims, a studio to reflect, and reflections that ground objects on the floor.

Per-pixel PBR + ACES filmic tone mapping in !!FP2.0

pbr3d.fp shades every one of the 1920 × 1080 pixels with metalness and roughness:

  • Schlick Fresnel without POW: x = 1 − N·V, x² = x·x, F = lerp(F0, 1, x²·x²·x), where F0 = lerp(0.04, albedo, metalness).
  • Four lights per pixel: a directional key light with a roughness-driven Blinn-Phong lobe normalized by (specExp + 8) · 0.0398, plus three coloured point lights with smooth inverse-square falloff.
  • ACES filmic tone mapping, c(2.51c + 0.03) / (c(2.43c + 0.59) + 0.14), so bright highlights roll off into soft cinema whites instead of clipping to harsh primaries—then x · rsq(x), a square root, as a cheap gamma.

Trig-free 360° studio IBL

Shiny gold and chrome look dead without something to reflect, and NV40 fragment programs hate atan2 and asin. So we generate a 256 × 128 procedural studio panorama (a warm overhead softbox, a cool cyan rim strip, a zenith ring light, a glow along the horizon) and sample it along R = 2(N·V)N − V with a trig-free, continuous 360° projection:

t = R.x / (|R.x| + |R.z| + 0.0001)
u = (R.z < 0) ? (0.75 - 0.25 * t) : (0.25 + 0.25 * t)
v = 0.5 - 0.48 * R.y

At +X (t = +1) both branches meet at u = 0.5; at −X (t = −1) they meet at 0 and 1 under GCM_TEXTURE_REPEAT. Zero trig instructions, zero seams—and the reflection fades with roughness, so mirror chrome reads as liquid metal while matte ceramic stays soft.

Real-time planar mirrors with the 8-bit stencil

That crisp upside-down golden torus knot in the marble floor isn’t screen-space trickery—it’s a classic hardware stencil pass using our Z24S8 buffer:

  1. Mask: draw the floor with colour and depth writes off, stamping stencil = 1.
  2. Reflect: where stencil == 1, mirror the scene across y = planeY (scale(1, −1, 1)), mirror the lights’ Y, flip the front-face winding (GCM_FRONTFACE_CW), and draw every reflectable opaque mesh upside down below the floor.
  3. Composite: clear only depth (GCM_CLEAR_Z), turn the stencil off, and draw the glossy floor over it with alpha 1 − reflectivity, then the upright scene.
05

Five wild hardware and toolchain bugs

Getting pixels onto a 20-year-old console from an Apple-silicon Mac (PSL1GHT in the hldtux/ps3dev Docker image, plus Rust nightly for powerpc64-sony-ps3) was half graphics programming and half detective work. Every one of these happened on real hardware—and if you ever hack on the RSX, this list may save you days.

1 · The GCC 13 strict-aliasing ghost in librsx.a

On the very first Three.js boot, the PocketJS HUD rendered razor-sharp—and the 3D background was pure #000000. We disassembled PSL1GHT’s prebuilt rsxSetFragmentProgramParameter inside librsx.a with ppu-objdump -dr and stared in disbelief:

  18: std  r11, 112(r1)   # zero-init 16 bytes on the stack
  20: std  r10, 120(r1)
  48: mr   r28, r6        # r28 = the value (never read!)
  d0: mr   r28, r3        # overwritten before it is copied
 104: addi r5, r1, 112    # passes the zeroed buffer
 110: bl   rsxInlineTransfer

Every fragment uniform we set was uploading (0, 0, 0, 0) into VRAM—exposure, sky colours, every light intensity. Our best reading: ppu-gcc 13.2.0 optimized the copy away under strict aliasing. Replacing it with our own 12-line memcpy-based set_fp_vec4() over rsxInlineTransfer fixed it immediately.

2 · cgcomp -a -v ignores write masks on o[HPOS]

With fragment uniforms fixed, the sky lit up—and zero 3D triangles appeared. Dumping the compiled vertex microcode of pbr3d.vp found the culprit in two seconds:

DP4 o[HPOS].x, v[0], c[0];   -> 6041ff80  (mask = XYZW!)
DP4 o[HPOS].y, v[0], c[1];   -> 6041ff80  (mask = XYZW!)
DP4 o[HPOS].z, v[0], c[2];   -> 6041ff80  (mask = XYZW!)
DP4 o[HPOS].w, v[0], c[3];   -> 6041ff80  (mask = XYZW!)

The vertex assembler ignores component write masks on output registers! All four DP4s wrote the full .xyzw, so every vertex in the universe collapsed to (w, w, w, w). Computing into R0.x … R0.w first and finishing with MOV o[HPOS], R0 produced distinct write masks—and the golden torus knot exploded onto the 1080p screen on the next deploy.

3 · cgcomp -a -f drops SUB, ABS and inline literals

We wrote raw !!FP2.0 for cgcomp -a -f (NVIDIA’s Cg compiler doesn’t run on ARM64 Linux), and inspecting the compiled .fpo binaries turned up four undocumented traps:

  • SUB R0, R1, R2; assembles to a 16-byte all-zero no-op—write ADD R0, R1, -R2;
  • ABS R0, R1; is silently dropped—use the modifier, MOV R0, |R1|;
  • Inline literals like {14.0}.x are read as R0—put every number in a named constant (uK0 … uK4)
  • A blank line inside !!FP2.0 segfaults the assembler

4 · The classic custom-renderer trap: camera.matrixWorldInverse

In Three.js, camera.updateMatrixWorld() updates camera.matrixWorld, not camera.matrixWorldInverse. WebGLRenderer.render() is the one that calls:

camera.matrixWorldInverse.copy(camera.matrixWorld).invert();

Forget that one line in a custom renderer and your camera stays stuck at the origin looking down −Z, no matter where you orbit it.

5 · The FIFO wall, and tuning for the NV40

Switching to the instanced demo—then 400 instances in one InstancedMesh—froze the RSX on frame one. Why? Each instance emits about 58 FIFO words (a constant-block load of 12 vec4s plus a draw), so 400 × 58 = 23,200 words, about 92 KB, blew straight past the end of PSL1GHT’s command segment mid-frame. We fixed it on both ends:

  • Safety: rsx_driver.c rewinds the FIFO to its start after every frame, and an ensure_fifo_space() guard in rsx3d.c rewinds mid-frame, so an arbitrarily large batch can never hang the GPU.
  • Speed: the point lights’ POW (LG2 + MUL + EX2) became repeated squaring (s² → s⁴ → s⁸ → s¹⁶), pbr3d.fp went from 16 to 13 registers so the NV40 keeps more fragments in flight, the demo writes instanceMatrix.array directly instead of calling Object3D.updateMatrix() per instance, and the wave became a 14 × 14 grid of 196 pillars.
  • Point sprites: adding MOV o[TEX0], v[0]; to unlit3d.vp put TEX0 in the vertex output mask, so the hardware’s GCM_POINT_SPRITE_TEX0 coordinates finally reached unlit3d.fp—and all 2,400 galaxy stars and 260 showroom embers lit up.
06

Live 1080p results on real PS3 hardware

Every frame below was captured natively at 1920 × 1080 from the RSX front buffer over our closed-loop DevShell on TCP :8623—which also hot-reloads app bundles in place without ever exiting to the XMB, and injects DualShock 3 input from the terminal.

The chrome and gold PBR showroom: a gold torus knot over a mirrored floor
Chrome & gold PBR showroom 25,990 triangles · 26 draws · stencil mirror · 20 fps
The instanced kinetic wave: 196 metallic pillars in a grid
Instanced kinetic wave 196 InstancedMesh pillars · per-instance colour · LineLoop · 16 fps
A ringed planet in front of a spiral galaxy of 2,400 points
Exoplanet & 2,400-star galaxy DataTexture planet and rings · point sprites · 30 fps
Twenty spheres from smooth to rough and from dielectric to metal
PBR material matrix 58,886 triangles · 5 × 4 roughness × metalness · mirror · 26 fps

With a DualShock 3 in hand: L1 / R1 switch scenes, the sticks orbit and zoom, △ toggles hardware wireframe, ○ toggles the mirror, □ pauses the orbit, and SELECT hides the HUD for a clean full-screen 1080p view.

None of these hits 60 fps yet. In three of the four, writing the 3D commands takes about 0.1 ms, so most of each frame goes somewhere we haven’t measured yet: QuickJS walking the scene on the PPU, the RSX shading two million PBR pixels (twice where there’s a mirror), or waiting on vsync. Profiling that is next.

And the work hasn’t stopped at these captures: the Cell’s six SPUs now run marching cubes and particles, and a second app flies through ThreeRT’s own Bistro and Zero-Day—baked offline into a PS3 scene format, rendered at 720p and scaled to 1080p—at 29–30 fps. That code is in pocket-nexus/pocketjs#786.

07

Why this matters for ThreeRT: RT means runtime

At first glance, running Three.js r187 on a 2006 PlayStation 3 sounds like a fun weekend stunt. In the context of ThreeRT, it is the boundary proof of a much bigger idea.

ThreeRT started as a hardware path tracer and has grown into a native runtime for Three.js—no browser between your scene and the GPU:

  • path: real-time path tracing at 60 fps on GPUs with ray-tracing hardware, nothing baked.
  • webgpu: Three.js r187 and its own WebGPURenderer, unchanged, running natively on macOS and Linux—a desktop app at 9.9 MB installed, 4.5 MB to download—and surfaces a browser simply can’t be, like a live 3D Wayland wallpaper on Omarchy (#300).

The PS3 completes the spectrum:

TierHow it runsHardware & APIWhat it proves
Flagship RTpathApple silicon, RTX, RDNA2+ (wgpu ray queries)real-time path tracing with zero baking
Modern nativewebgpuMetal on macOS, Vulkan on Linux (wgpu + JavaScriptCore + PocketJS)sub-10 MB native apps and OS surfaces, with the same pixels as Chrome
Console / legacy GPUthe PS3 port PocketJS, experimental2006 PlayStation 3: NV40-class RSX, raw FIFO, NV40 assembly, QuickJSno browser, no Electron, no WebGPU, no Vulkan, no JIT—still vanilla Three.js r187

If vanilla three@0.187.0 can drive real-time PBR, studio IBL and hardware-stenciled mirror reflections on a 20-year-old PlayStation 3 at 1080p, there is no reason Three.js has to stay trapped inside a browser tab ever again.

The PS3 port is experimental, needs a console with custom firmware, and is built in PocketJS (platforms/ps3). How the three ways of running differ: RENDERING-METHODS.md.