Skip to content
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 2d targets to and from layers of 3d textures #29710

Merged
merged 11 commits into from
Oct 23, 2024

Conversation

gkjohnson
Copy link
Collaborator

@gkjohnson gkjohnson commented Oct 21, 2024

Related issue: #29688

Description

This PR addresses allows for passing in 2d or 3d textures into the src or destination arguments of copyTextureToTexture3D. In the case of a 2d it is treated effectively as a single-layer 3d texture so individual layers can be copied in and out of 3d textures.

Ultimately this means that you can pass two 2d textures into the function to copy data between them, rendering the copyTextureToTexture function for 2d targets redundant.

--

I'm still working out some question I have about copying mipmaps but I think that's separate.

edit I've created a stack overflow question here asking about how to copy a mip map from a source texture.

Copy link

github-actions bot commented Oct 21, 2024

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 692.88
171.51
691.55
171.4
-1.32 kB
-115 B
WebGPU 818.62
220.76
818.66
220.77
+43 B
+8 B
WebGPU Nodes 818.13
220.62
818.17
220.63
+43 B
+9 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 465.09
112.28
463.72
112.16
-1.37 kB
-118 B
WebGPU 539.55
145.72
539.55
145.72
+0 B
+0 B
WebGPU Nodes 495.55
135.53
495.55
135.53
+0 B
+0 B

@Mugen87 Mugen87 added this to the r170 milestone Oct 21, 2024

<h3>
[method:undefined copyTextureToTexture3D]( [param:Texture srcTexture], [param:Texture dstTexture], [param:Box3 srcRegion], [param:Vector3 dstPosition], [param:Number level] )
[method:undefined copyTextureToTexture]( [param:Texture srcTexture], [param:Texture dstTexture], [param:Box3 srcRegion], [param:Vector3 dstPosition], [param:Number level] )
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function can technically take Box2 and Vector2 as arguments, as well. Is there a typical way to signify that here?

Copy link
Collaborator

@Mugen87 Mugen87 Oct 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we separated multiple types with a | so far.

E.g. https://threejs.org/docs/index.html#examples/en/exporters/DRACOExporter.parse

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm it's a bit verbose looking and not super easy to read but I supposed it can be addressed later -

image

@gkjohnson
Copy link
Collaborator Author

🎉

And I'll ask here just in case - but are you aware of any way to copy texture mip map data from a src texture to a dst texture mip map? A la the Stack overflow question? It's not clear that it's possible from the WebGL APIs...

@gkjohnson gkjohnson merged commit 3293572 into mrdoob:dev Oct 23, 2024
12 checks passed
@gkjohnson gkjohnson deleted the texture-copy-2d-3d branch October 23, 2024 09:31
@Mugen87
Copy link
Collaborator

Mugen87 commented Oct 23, 2024

No, sorry :(.

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.

2 participants