Skip to content

Conversation

sunag
Copy link
Collaborator

@sunag sunag commented Sep 19, 2025

Related issue: #31730

Description

Instead of using RenderTargets, the current implementation considers CanvasTarget the current canvas, always having one as default, and it cannot be null.

The main motivation, besides bringing these new WebGPU features, is to inspect the nodes individually through the new inspector.

The API follows @mrdoob ’s suggestion. #31730 (comment)

// -- setup --
const canvas = document.querySelector( '#mycanvas'  );
const canvasTarget = new THREE.CanvasTarget( canvas );

// -- loop --
renderer.setCanvasTarget( canvasTarget );
renderer.render( scene, camera );

Copy link

github-actions bot commented Sep 19, 2025

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 338.24
79.14
338.24
79.14
+0 B
+0 B
WebGPU 584.78
161.56
586.56
161.9
+1.78 kB
+344 B
WebGPU Nodes 583.39
161.32
585.17
161.66
+1.78 kB
+344 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 469.7
113.74
469.7
113.74
+0 B
+0 B
WebGPU 654.25
177.07
656.01
177.4
+1.76 kB
+332 B
WebGPU Nodes 608.25
166.24
610.01
166.57
+1.76 kB
+334 B

@sunag
Copy link
Collaborator Author

sunag commented Sep 19, 2025

@sunag sunag marked this pull request as ready for review September 20, 2025 00:20
@sunag sunag added this to the r181 milestone Sep 20, 2025
@sunag sunag merged commit 6dff7ce into mrdoob:dev Sep 21, 2025
9 checks passed
@sunag sunag deleted the dev-canvastarget branch September 21, 2025 01:25
@mrdoob
Copy link
Owner

mrdoob commented Sep 21, 2025

After seeing the shape and properties of CanvasTarget I feel like RenderOutput would be a better name.

// -- setup --
const canvas = document.querySelector( '#mycanvas'  );
const output = new THREE.RenderOutput( canvas );

// -- loop --
renderer.setRenderOutput( output );
renderer.render( scene, camera );

Regarding this:

The idea of ​​having .setOutputRenderTarget() is to define a final output, the one that will be displayed to the user. Currently, it would be XRRenderTarget or CanvasRenderTarget.

How would the XRRenderTarget look like with this CanvasTarget/RenderOutput API?

@sunag
Copy link
Collaborator Author

sunag commented Sep 21, 2025

How would the XRRenderTarget look like with this CanvasTarget/RenderOutput API?

I think RenderOutput should be a base class of CanvasTarget and XRRenderTarget , then we can think of a strategy for this.

And if so, should CanvasTarget still be called that? Wouldn't it be more appropriate for it to be named based on the extended class names, something like CanvasOutput and XRRenderOutput?

@Mugen87
Copy link
Collaborator

Mugen87 commented Sep 26, 2025

After more testing on dev, I have noticed that this PR broke the new HDR demo from #31893. You just see a white screen but without the glowing after image effect.

I can confirm reverting this PR fixes webgpu_hdr.

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.

3 participants