-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
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
WebGLRenderer: Allow for copying textures from the canvas, remove copyFramebufferToTexture #29772
base: dev
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
copyTextureToTexture
so it can takenull
as 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.