3D engine that AI agents drive
JavaScript 3d3d-engineagentic-aiai-agentsblenderclaude-codegame-enginegaussian-splattinggltfjavascriptmcpmcp-servermodel-context-protocolpath-tracerpath-tracingpbrrenderingthreejs-alternativewebgl2webgpu
Merge pull request #2587 from codepawl/2576-realtime-tracer-setup-leaks
Nguyen Xuan An1508d543b32d
diff --cc docs/path-tracer.mdindex 1e09c71c,c197b144..a5eba0f3--- a/docs/path-tracer.md+++ b/docs/path-tracer.md@@@ -348,9 -348,9 +348,9 @@@ Proof of the three checks of issue #62## Real-time hybrid view (issue #624)- `crucible/addons/path-tracer-realtime` (`createRealtimeTracer(scene, { width, height, bounces, ... })`, then `frame(camera)` for every picture) draws the WebGL2 tracer fast enough to move the camera. It shares the WebGL2 context of the GPU still, so one render at a time owns it, and it draws to `canvas` (an `OffscreenCanvas` or a canvas element, 8 bit, ACES view transform). `readFrame()` returns the same picture as bytes. The pieces, each in its own module so they can move to the WebGPU backend:+ `crucible/addons/path-tracer-realtime` (`createRealtimeTracer(scene, { width, height, bounces, ... })`, then `frame(camera)` for every picture) draws the WebGL2 tracer fast enough to move the camera. It shares the WebGL2 context of the GPU still, so one render at a time owns it, and it draws to `canvas` (an `OffscreenCanvas` or a canvas element, 8 bit, ACES view transform). `readFrame()` returns the same picture as bytes. The pieces, each in its own module so they can move to the WebGPU backend: A scene it refuses (no parts, over the part cap, local volumes) is checked before any GL object is made or released, so a refused `update({ parts })` keeps the scene the tracer had and a refused first scene leaves nothing allocated.-- **Half-size tracing.** One path per pixel and frame at half the output size (`resolutionDivisor`, 2), two bounces (`bounces`, 2). `resolutionDivisor`, `historyLimit` and `cacheCellSize` must be above 0 and `filterIterations` a whole number from 0 to 16, and `width` and `height` whole numbers whose traced size (over `resolutionDivisor`) stays from 16 to 4096, or the tracer refuses them. The first hit picks one light by importance instead of tracing a shadow ray to every light, which the denoiser averages over frames.+- **Half-size tracing.** One path per pixel and frame at half the output size (`resolutionDivisor`, 2), two bounces (`bounces`, 2). `resolutionDivisor` and `cacheCellSize` must be above 0, `historyLimit` at least 1 and `filterIterations` a whole number from 0 to 16, and `width` and `height` whole numbers whose traced size (over `resolutionDivisor`) stays from 16 to 4096, or the tracer refuses them. The first hit picks one light by importance instead of tracing a shadow ray to every light, which the denoiser averages over frames.- **Radiance cache** (`src/path-tracer-radiance-cache.js`, SHaRC style). A cell is the quantized position (cells double in size each time the distance from the eye doubles past 64 cells) and the quantized normal of a surface point, hashed into 2^20 slots with no collision check (about 0.4% of 7,500 test cells collided). The last hit of a path reads its cell instead of tracing on; the hit before it writes what the rest of the path brought back, and a point pass adds the records into the cells with additive blending (WebGL2 has no atomics), as a running average of up to 128 records. The cache reads as diffuse. It needs the scene to rest: a new scene empties it.- **Temporal denoiser and upsampler** (`src/path-tracer-temporal-denoise.js`, `src/path-tracer-reprojection.js`, SVGF style). The light is divided by the albedo, reprojected history (bilinear, rejected where distance or normal differ) is blended in over up to 48 frames, the variance comes from the history of the luminance (from the 3 by 3 neighbours while the history is short), four a-trous passes filter with plane distance, normal and variance guided luminance weights, and a joint bilateral upsample to the output size multiplies the albedo history back in. A sample far above its neighbours is clamped while the history is short.