Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

Record the clean demo room time and the GPU against Cycles scores (issue #302)

Nguyen Xuan An09ad5adf4a46
diff --git a/bench/reference/path-tracer-gpu.json b/bench/reference/path-tracer-gpu.json
new file mode 100644
index 00000000..3cf2fbd1
--- /dev/null
+++ b/bench/reference/path-tracer-gpu.json
@@ -0,0 +1,126 @@
+{
+ "metric": "FLIP (LDR), mean error against Cycles, lower is better",
+ "scores": {
+ "brick-flat": {
+ "pathtracer-vs-cycles": 0.0246,
+ "seconds": 4.3,
+ "samples": 64,
+ "averageSamples": 64,
+ "ignored": []
+ },
+ "brick-graph": {
+ "pathtracer-vs-cycles": 0.0809,
+ "seconds": 72.9,
+ "samples": 64,
+ "averageSamples": 64,
+ "ignored": []
+ },
+ "brick-room": {
+ "pathtracer-vs-cycles": 0.2587,
+ "seconds": 7.1,
+ "samples": 64,
+ "averageSamples": 64,
+ "ignored": []
+ },
+ "brushed-film": {
+ "pathtracer-vs-cycles": 0.0599,
+ "seconds": 6.6,
+ "samples": 64,
+ "averageSamples": 64,
+ "ignored": [
+ "anisotropy is ignored.",
+ "iridescence is ignored."
+ ]
+ },
+ "car-paint": {
+ "pathtracer-vs-cycles": 0.0324,
+ "seconds": 5.7,
+ "samples": 64,
+ "averageSamples": 64,
+ "ignored": []
+ },
+ "character": {
+ "pathtracer-vs-cycles": 0.0288,
+ "seconds": 5,
+ "samples": 64,
+ "averageSamples": 64,
+ "ignored": [
+ "gltf materials are traced as plain surfaces."
+ ]
+ },
+ "fog": {
+ "pathtracer-vs-cycles": 0.0312,
+ "seconds": 7.1,
+ "samples": 64,
+ "averageSamples": 64,
+ "ignored": [
+ "volumeFog.ambient is not added: the fog is lit by the traced lights and sky."
+ ]
+ },
+ "foliage": {
+ "pathtracer-vs-cycles": 0.1002,
+ "seconds": 12.8,
+ "samples": 64,
+ "averageSamples": 64,
+ "ignored": [
+ "foliage materials are traced as plain surfaces."
+ ]
+ },
+ "glass": {
+ "pathtracer-vs-cycles": 0.0386,
+ "seconds": 5.2,
+ "samples": 64,
+ "averageSamples": 64,
+ "ignored": []
+ },
+ "light-linking": {
+ "pathtracer-vs-cycles": 0.0213,
+ "seconds": 4.3,
+ "samples": 64,
+ "averageSamples": 64,
+ "ignored": []
+ },
+ "lit-interior": {
+ "pathtracer-vs-cycles": 0.0769,
+ "seconds": 5.5,
+ "samples": 64,
+ "averageSamples": 64,
+ "ignored": []
+ },
+ "long-street": {
+ "pathtracer-vs-cycles": 0.0291,
+ "seconds": 4.1,
+ "samples": 64,
+ "averageSamples": 64,
+ "ignored": []
+ },
+ "material-spheres": {
+ "pathtracer-vs-cycles": 0.0449,
+ "seconds": 5.8,
+ "samples": 64,
+ "averageSamples": 64,
+ "ignored": []
+ },
+ "metal": {
+ "pathtracer-vs-cycles": 0.0439,
+ "seconds": 6.2,
+ "samples": 64,
+ "averageSamples": 64,
+ "ignored": []
+ },
+ "outdoor-hdri": {
+ "pathtracer-vs-cycles": 0.0226,
+ "seconds": 4.4,
+ "samples": 64,
+ "averageSamples": 64,
+ "ignored": []
+ },
+ "spot-area": {
+ "pathtracer-vs-cycles": 0.0262,
+ "seconds": 4.5,
+ "samples": 64,
+ "averageSamples": 64,
+ "ignored": []
+ }
+ }
+}
diff --git a/bench/reference/path-tracer.json b/bench/reference/path-tracer.json
index 847ac4a0..9446b43c 100644
--- a/bench/reference/path-tracer.json
+++ b/bench/reference/path-tracer.json
@@ -3,58 +3,54 @@
"scores": {
"brick-flat": {
"pathtracer-vs-cycles": 0.0246,
- "seconds": 24.1,
+ "seconds": 36.9,
"samples": 64,
"averageSamples": 64,
"ignored": []
},
"brick-graph": {
- "pathtracer-vs-cycles": 0.0805,
- "seconds": 23.9,
+ "pathtracer-vs-cycles": 0.0809,
+ "seconds": 25.6,
"samples": 64,
"averageSamples": 64,
"ignored": []
},
"brick-room": {
"pathtracer-vs-cycles": 0.2587,
- "seconds": 98.5,
+ "seconds": 133.6,
"samples": 64,
"averageSamples": 64,
"ignored": []
},
"brushed-film": {
"pathtracer-vs-cycles": 0.0599,
- "seconds": 35.9,
+ "seconds": 30.3,
"samples": 64,
"averageSamples": 64,
- "ignored": []
+ "ignored": [
+ "anisotropy is ignored.",
+ "iridescence is ignored."
+ ]
},
"car-paint": {
"pathtracer-vs-cycles": 0.0324,
- "seconds": 36.4,
+ "seconds": 51.6,
"samples": 64,
"averageSamples": 64,
"ignored": []
},
"character": {
"pathtracer-vs-cycles": 0.0287,
- "seconds": 29,
+ "seconds": 25.4,
"samples": 64,
"averageSamples": 64,
"ignored": [
"gltf materials are traced as plain surfaces."
]
},
- "emissive-sign": {
- "pathtracer-vs-cycles": 0.08,
- "seconds": 62.9,
- "samples": 64,
- "averageSamples": 64,
- "ignored": []
- },
"fog": {
"pathtracer-vs-cycles": 0.0312,
- "seconds": 85.3,
+ "seconds": 41.4,
"samples": 64,
"averageSamples": 64,
"ignored": [
@@ -63,7 +59,7 @@
},
"foliage": {
"pathtracer-vs-cycles": 0.1001,
- "seconds": 63.4,
+ "seconds": 84.9,
"samples": 64,
"averageSamples": 64,
"ignored": [
@@ -72,56 +68,56 @@
},
"glass": {
"pathtracer-vs-cycles": 0.0385,
- "seconds": 31.9,
+ "seconds": 56.1,
"samples": 64,
"averageSamples": 64,
"ignored": []
},
"light-linking": {
"pathtracer-vs-cycles": 0.0213,
- "seconds": 29.2,
+ "seconds": 42.9,
"samples": 64,
"averageSamples": 64,
"ignored": []
},
"lit-interior": {
"pathtracer-vs-cycles": 0.0769,
- "seconds": 78.3,
+ "seconds": 82.7,
"samples": 64,
"averageSamples": 64,
"ignored": []
},
"long-street": {
"pathtracer-vs-cycles": 0.0291,
- "seconds": 43.9,
+ "seconds": 55.8,
"samples": 64,
"averageSamples": 64,
"ignored": []
},
"material-spheres": {
"pathtracer-vs-cycles": 0.0449,
- "seconds": 45.6,
+ "seconds": 64.3,
"samples": 64,
"averageSamples": 64,
"ignored": []
},
"metal": {
"pathtracer-vs-cycles": 0.0439,
- "seconds": 31.9,
+ "seconds": 26.2,
"samples": 64,
"averageSamples": 64,
"ignored": []
},
"outdoor-hdri": {
"pathtracer-vs-cycles": 0.0226,
- "seconds": 19.6,
+ "seconds": 13.8,
"samples": 64,
"averageSamples": 64,
"ignored": []
},
"spot-area": {
"pathtracer-vs-cycles": 0.0261,
- "seconds": 26.9,
+ "seconds": 35,
"samples": 64,
"averageSamples": 64,
"ignored": []
diff --git a/changes/302.md b/changes/302.md
index 3eefc7bf..800ee725 100644
--- a/changes/302.md
+++ b/changes/302.md
@@ -1 +1 @@
-- Add a GPU backend to the path tracer, `backend: 'gpu'` (issue #302): the same algorithm and random numbers in a WebGL2 fragment shader, with the BVH, materials, maps, lights and sky in float textures, inside the path-tracer addon only. The 1920 by 1080 demo room at 64 samples took 55.8 s against 585.9 s on the CPU tracer, and GPU against CPU FLIP was 0.0001 to 0.0018 on the 16 reference scenes. `docs/webgpu-decision.md` records WebGL2 over WebGPU for this offline work.
+- Add a GPU backend to the path tracer, `backend: 'gpu'` (issue #302): the same algorithm and random numbers in a WebGL2 fragment shader, with the BVH, materials, maps, lights and sky in float textures, inside the path-tracer addon only. The 1920 by 1080 demo room at 64 samples took 58.2 s against 585.9 s on the CPU tracer, and GPU against CPU FLIP was 0.0001 to 0.0018 on the 16 reference scenes. `docs/webgpu-decision.md` records WebGL2 over WebGPU for this offline work.
diff --git a/docs/path-tracer.md b/docs/path-tracer.md
index 5e1baa42..83f2c07a 100644
--- a/docs/path-tracer.md
+++ b/docs/path-tracer.md
@@ -58,7 +58,7 @@ The same scene and options give the same bytes. Random numbers come from a hash
`backend: 'gpu'` (issue #302) runs the same algorithm in a WebGL2 fragment shader (`src/path-tracer-gpu.js`, loaded only for this backend, so a CPU render and the core bundle do not carry it). The BVH, triangles, materials, maps, lights and the environment table are packed into float textures (`src/path-tracer-gpu-pack.js`), the random numbers are the same integer hash and PCG stream as the CPU tracer and are drawn in the same order, and each sample adds into four float targets (colour and depth, albedo, normal, luminance and its square) that feed the same denoiser. Float32 maths and a 24-bit random value make the pixels differ a little from the CPU tracer: FLIP (LDR) of GPU against CPU at the same seed was 0.0001 to 0.0018 on the 16 path tracer reference scenes at 480 by 270 and 32 samples. It needs a page with WebGL2, `EXT_color_buffer_float` and `EXT_float_blend`, and throws without them, so choose it only where those exist. It traces everything the CPU tracer does (lights with linking, all materials and maps including emissive maps, glass, volume fog, the sky); it does not use `noiseThreshold` (every pixel draws every sample) or `threads`, and a sample that produced a NaN or an infinity counts as black. The first still of a page compiles the kernel (13 to 30 s), later ones reuse it.
-The 1920 by 1080 still of the demo room at 64 samples took 55.8 s on the GPU (RTX 3060, including 13.0 s of compiling, the BVH build and the denoiser) against 585.9 s on the CPU tracer (measured 2026-11-03; see [the WebGPU decision](webgpu-decision.md) for the choice of WebGL2 over WebGPU). `node bench/reference/gpu-compare.mjs <directory> <scene or recipe.json> --backend both` draws a scene with both backends, and `bench/reference/flip-compare.py` scores them against each other and against Cycles. Render jobs do not select the GPU backend yet.
+The 1920 by 1080 still of the demo room at 64 samples took 58.15 s on the GPU (RTX 3060, clean image, including 10.3 s of compiling with a warm shader cache, the BVH build and the denoiser; a cold compile measured 30 s on an earlier version of the kernel, which would put it over 60 s) against 585.9 s on the CPU tracer (measured 2026-11-03; see [the WebGPU decision](webgpu-decision.md) for the choice of WebGL2 over WebGPU). Against Cycles (FLIP, 960 by 540, 64 samples, 16 scenes, `bench/reference/path-tracer.json` for the CPU and `path-tracer-gpu.json` for the GPU), the two backends scored within 0.0002 of each other on every scene (largest gap 0.0001 to 0.0002 on `foliage`, `glass`, `character`), so each keeps its score within the 0.005 bound (measured 2026-11-04). The GPU run took 4 to 13 s per scene after the first scene's compile. `node bench/reference/gpu-compare.mjs <directory> <scene or recipe.json> --backend both` draws a scene with both backends, and `bench/reference/flip-compare.py` scores them against each other and against Cycles. Render jobs do not select the GPU backend yet.
## Speed
diff --git a/docs/webgpu-decision.md b/docs/webgpu-decision.md
index a0859e15..86a3ba53 100644
--- a/docs/webgpu-decision.md
+++ b/docs/webgpu-decision.md
@@ -8,7 +8,7 @@ The trigger named below ("a feature measured as too slow on the CPU") was met by
Why WebGL2 fragment (measured on this machine, 2026-11-03, RTX 3060 shared with other sessions, Chrome with ANGLE on Direct3D 11, headless):
-- It reached the target without compute. The 1920 by 1080 still of `tests/fixtures/demo-room.recipe.json` (181,708 triangles, 64 samples, 8 bounces, the 8-thread CPU tracer took 585.9 s) took 55.8 s end to end on the GPU in the first full run, of which 13.0 s was compiling the kernel and about 12 s was the denoiser and the BVH build (the log of that run: `seconds` 55.81, `tracedSeconds` 43.80, `compileSeconds` 13.03).
+- It reached the target without compute. The 1920 by 1080 still of `tests/fixtures/demo-room.recipe.json` (181,708 triangles, 64 samples, 8 bounces, the 8-thread CPU tracer took 585.9 s) took 58.15 s end to end on the GPU (`seconds` 58.15, `tracedSeconds` 40.67, `compileSeconds` 10.32, warm shader cache; the rest is the BVH build and the denoiser).
- The same kernel, in the same random-number order as the CPU tracer, gives the same picture: GPU against CPU FLIP (LDR, mean) was 0.0001 to 0.0018 on all 16 path tracer reference scenes at 480 by 270 and 32 samples (measured; `bench/reference/gpu-compare.mjs` and `flip-compare.py`). Float32 against float64 and a 24-bit random value are the only differences.
- On those 16 scenes the GPU tracer took 0.5 to 1.8 s against 1.6 to 9.0 s for the CPU tracer on 8 threads, both including the denoiser (measured).
- It needs no new API surface: WebGL2 is what the job pages already use, `EXT_color_buffer_float` and `EXT_float_blend` are present on the RTX 3060 in headless Chrome, and a page without them falls back to the CPU tracer by choosing `backend: "cpu"` (the default).