Skip to content

PassNode: Add compileAsync(). #31501

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 25, 2025
Merged

PassNode: Add compileAsync(). #31501

merged 1 commit into from
Jul 25, 2025

Conversation

Mugen87
Copy link
Collaborator

@Mugen87 Mugen87 commented Jul 25, 2025

Fixed #31220.

Description

The PR makes it possible to precompile scene passes by introducing compileAsync() on PassNode level. Typical usage:

const scenePass = pass( scene, camera );
scenePass.setMRT( mrt( {
	output,
	emissive
} ) );

const outputPass = scenePass.getTextureNode( 'output' );
const emissivePass = scenePass.getTextureNode( 'emissive' );

// precompile pass after the configuration is complete

await scenePass.compileAsync( renderer );

So when the animation loop starts and the pass is rendered for the first time, the frame time should be lower due to the pre-compilation.

Copy link

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 338.37
78.9
338.37
78.9
+0 B
+0 B
WebGPU 560.72
155.17
560.91
155.22
+198 B
+47 B
WebGPU Nodes 559.64
154.96
559.84
155
+198 B
+48 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Before After Diff
WebGL 469.75
113.6
469.75
113.6
+0 B
+0 B
WebGPU 635.88
172.08
636.08
172.13
+198 B
+50 B
WebGPU Nodes 590.53
161.32
590.73
161.37
+198 B
+50 B

@sunag sunag added this to the r179 milestone Jul 25, 2025
@sunag sunag merged commit fa035e8 into mrdoob:dev Jul 25, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Calling renderer.compileAsync before a MRT breaks the renderer
2 participants