WebGPURenderer: Introduce CanvasRenderTarget#31730
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
|
|
||
| this._renderOutput( renderTarget ); | ||
|
|
||
| this.setRenderTarget( previousRenderTarget, activeCubeFace, activeMipmapLevel ); |
There was a problem hiding this comment.
Do you mind explaining why you have added this line?
We should check if this addition does not break XR.
There was a problem hiding this comment.
After setting setRenderTarget() as outputRenderTarget it does not restore the previous state, making the current getRenderTarget() the same as getOutputRenderTarget() after the render, thus being a bug.
There was a problem hiding this comment.
I try to make a test with a Quest 2 tomorrorw. Just to be on the safe side since r180 is released next week.
|
|
||
| if ( options.renderTarget ) { | ||
|
|
||
| options.format = this.backend.utils.getCurrentColorFormat( options.renderTarget ); |
There was a problem hiding this comment.
Would it be possible to keep updating the options object as before?
options is not only used in createTexture() but also in subsequent code like updateTexture(). To avoid side effects, it would be beneficial if options does not loose any information with these changes.
There was a problem hiding this comment.
Could you please also temporarily update the builds? I can then build a rawgit URL for WebXR testing.
There was a problem hiding this comment.
@Mugen87 Interestingly, the AA problem is not related to this PR but in WebGPU / WebGPUBackend. I haven't
discovered the origin yet, if you have any suggestions? I went back a few releases to test and the problem remains.
| WebGPUBackend | WebGLBackend |
|---|---|
![]() |
![]() |
| https://jsfiddle.net/8oxjL7y1/1/ | https://jsfiddle.net/8oxjL7y1/2/ |
There was a problem hiding this comment.
Um, is this issue related to flat shading? When comparing without AA the WebGL and WebGPU backend, I can see rendering differences at the edges. WebGLRenderer matches with the WebGL backend, btw.
The MSAA is just emphasizing the issue in WebGPU.
…hree.js into dev-canvas-render-target
|
What do you think about renaming it to // -- setup --
const canvas = document.querySelector( '#mycanvas' );
const canvasTarget = new THREE.CanvasTarget( canvas );
// -- loop --
renderer.setCanvasTarget( canvasTarget );
renderer.render( scene, camera ); |
The idea of having I'll do some experiments to create a |



Closes #27628
Description
@aardgoose did a great job on PR #27628; this PR is a reinterpretation with a focus on simplification given the renderer’s current times.
With
CanvasRenderTargetit’s possible to use multiple canvases sharing existing resources—such as the cache—from the sameRenderer. Since the previous process, likewebgpu_multiple_elements, can bring other difficulties—because it is a whole canvas on the screen rendering only the scissor—or creating a newRendererwith a new canvas does not reuse the previous renderer’s caches, this feature becomes the most recommended for this application, given that the focus is only the WebGPU backend; at least in this PR it will be used exclusively for this backend.Usage
Note that
renderer.setOutputRenderTarget()must respect therenderer.outputColorSpace.