WebGLRenderer: Allow for copying textures from the canvas, remove copyFramebufferToTexture#29772
WebGLRenderer: Allow for copying textures from the canvas, remove copyFramebufferToTexture#29772gkjohnson wants to merge 17 commits intomrdoob:devfrom
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
| texture = new THREE.FramebufferTexture( textureSize, textureSize ); | ||
| texture = new THREE.DataTexture( new Uint8Array( textureSize * textureSize * 4 ), textureSize, textureSize ); | ||
| texture.needsUpdate = true; |
There was a problem hiding this comment.
Creating an "empty" texture that is only useful for copying data into, as FramebufferTexture was, is a bit more awkward, now. In the past I've used RenderTargets to serve as "empty" texture vessels for copying data around into but there's still some extra memory overhead in that case (depth buffers, etc).
| const currentTarget = this.getRenderTarget(); | ||
|
|
||
| this.setRenderTarget( null ); | ||
| textures.setTexture2D( dstTexture, 0 ); | ||
| _gl.copyTexSubImage2D( _gl.TEXTURE_2D, dstLevel, dstX, dstY, minX, minY, width, height ); | ||
| state.unbindTexture(); | ||
| this.setRenderTarget( currentTarget ); |
There was a problem hiding this comment.
I'm not sure if there's a better way to do this without calling "setRenderTarget"
# Conflicts: # docs/api/en/renderers/WebGLRenderer.html # src/renderers/WebGLRenderer.js
|
cc @Mugen87 what are your thoughts on this? I'm hoping it cuts down on some API redundancy with copyTextureToTexture. Happy to adjust it however and remove the last couple uses of copyFramebufferToTexture in examples. |
|
FYI: I've noticed the PR but I'm currently focusing on bug fixing/support in |
Related issue: #21734
Depends on #29769
Description
This PR adjusts
copyTextureToTextureso it can takenullas the first "srcTexture" argument so data can be copied from the "canvas" frame buffer, removing the need for a separate "copyFramebufferToTexture" function since this was the only remaining use case after #29662 was merged. Since this function was the only documented reason forFrameBufferTexture, that has been removed, as well.The LensFlare addon is the last thing that needs to be changed before this PR is ready but I'll wait for feedback before making further changes.