-
-
Notifications
You must be signed in to change notification settings - Fork 35.7k
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
WebGLBackend: Bring back 3D functionality for copyTextureToTexture #30584
WebGLBackend: Bring back 3D functionality for copyTextureToTexture #30584
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
@@ -699,68 +699,90 @@ class WebGLTextureUtils { | |||
* @param {Texture} dstTexture - The destination texture. | |||
* @param {?Vector4} [srcRegion=null] - The region of the source texture to copy. |
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.
Do you mind fixing the parameter type of srcRegion
?
*/ | ||
copyTextureToTexture( srcTexture, dstTexture, srcRegion = null, dstPosition = null, level = 0 ) { | ||
copyTextureToTexture( srcTexture, dstTexture, srcRegion = null, dstPosition = null, srcLevel = 0, dstLevel = 0 ) { |
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.
Do you mind updating all copyTextureToTexture()
signatures in WebGPURenderer
? For that, you have to update Renderer.copyTextureToTexture()
, Backend.copyTextureToTexture()
(the interface definition) and both backends.
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.
Cool I've updated the signatures too, hopefully it's looking alright
3cb654b
to
b72a191
Compare
src/renderers/common/Renderer.js
Outdated
*/ | ||
copyTextureToTexture( srcTexture, dstTexture, srcRegion = null, dstPosition = null, level = 0 ) { | ||
copyTextureToTexture( srcTexture, dstTexture, srcRegion = null, dstPosition = null, level = 0, dstLevel = 0 ) { |
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.
Can you please rename level
to srcLevel
?
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.
Fixed, I've set dstLevel = null
which is the same as the original WebGLRenderer as well.
2d401d7
to
008362f
Compare
// gather the necessary dimensions to copy | ||
let width, height, depth, minX, minY, minZ; | ||
let dstX, dstY, dstZ; | ||
const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[ dstLevel ] : srcTexture.image; |
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.
This bit isn't correct. The default value of dstLevel
must be 0
otherwise you end up with srcTexture.mipmaps[ null ]
.
Please change the default value of dstLevel
to 0
in all signatures as well in #30618.
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.
Regarding your comment in #30584 (comment): The signature in WebGLRenderer
can't be used as a template since the value is null
for backwards compatibility reason, AFAICS. Besides, it is set to 0
in the first if
statement.
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.
Ah yes that makes sense, I have updated them to use dstLevel = 0 by default now.
93a1072
to
38be18a
Compare
Fix interface method, see #30584.
Issue
#30619
Description
In the WebGLBackend, copyTextureToTexture has only implemented copying for 2D textures.
This PR uses parts of the code from the original GL renderer to add functionality for copying between 2D and 3D textures in new WebGL fallback renderer.