Nodes: Introduce renderer.nodeBuilderStateProvider for ahead-of-time compiled shaders - #34070
Open
RenaudRohlinger wants to merge 1 commit into
Open
Nodes: Introduce renderer.nodeBuilderStateProvider for ahead-of-time compiled shaders#34070RenaudRohlinger wants to merge 1 commit into
RenaudRohlinger wants to merge 1 commit into
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
RenaudRohlinger
force-pushed
the
nodes-builder-state-provider
branch
2 times, most recently
from
July 19, 2026 11:48
fe759f0 to
9c25f74
Compare
RenaudRohlinger
force-pushed
the
nodes-builder-state-provider
branch
from
July 19, 2026 12:57
9c25f74 to
9ce97f0
Compare
RenaudRohlinger
marked this pull request as ready for review
July 19, 2026 13:47
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Related issue: #31674
Follow-up to: #32984
Description
Building a TSL material or compute node runs
nodeBuilder.build()on the render thread. #32984 madecompileAsync()responsive by yielding during that work, but the complete TSL-to-native-shader build still runs, and first-render and compute paths remain synchronous.Applications that own a fixed set of TSL materials or compute kernels can solve a narrower case ahead of time: capture the generated WGSL or GLSL and the small amount of binding metadata during development, store that artifact as JSON, then hydrate a fresh renderer-local builder state on a later page load. This skips work that has already been done. Today, that is impossible without patching
three.webgpu.js, because there is no interception point beforenodeBuilder.build().We use this approach in production. On a fluid-simulation scene with 25 materials and kernels, first-load node-build time drops from 97 ms to 22 ms; the remaining three internal builds are intentionally not captured.
This draft adds one opt-in seam:
renderer.nodeBuilderStateProvider, defaulting tonull. On a cache miss,NodeManagerasksgetForRender( renderObject, NodeBuilderState )orgetForCompute( computeNode, NodeBuilderState )for a prebuilt state. Passing the private constructor lets a provider hydrate persisted artifacts into a fresh state without exporting renderer internals. Returningnullorundefinedpreserves the existing live-build path, cache behavior, and bookkeeping.Demo
Run the JSFiddle demo (source)
The demo uses an internal shader-capture tool to capture (which will be presented at the Three.js Conference in Paris) one procedural TSL material into a 17 KB JSON artifact containing its WGSL and binding recipes. The toggle creates a fresh renderer in either live or precompiled mode, and remembers the selection for later runs or refreshes. Live mode performs one TSL graph build; precompiled mode fetches the stored artifact, hydrates one fresh
NodeBuilderState, renders the same procedural image, and reports zero live TSL builds.Open it in a WebGPU-capable browser, then switch from Live TSL to Precompiled JSON.