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: Correctly generate mipmaps for 3D & Array RenderTargets #29678

Merged
merged 3 commits into from
Oct 17, 2024

Conversation

gkjohnson
Copy link
Collaborator

@gkjohnson gkjohnson commented Oct 17, 2024

Fixed #29628

Description

This PR ensures that the correct target type is passed into "bindTexture" for array and 3d render targets.

I've tested this with my 3d tiles use case and it works but the downside is that it's extremely slow and causes noticeable stalls (sometimes for what feels like almost a second or more) since gl.generateMipmap will regenerate the mipmaps for the whole volume target when just a single layer has been rendered to. This is especially problematic when rendering multiple layers per frame since that means the mip chain for the whole 3d texture will be generated every render (in this case ~256x256x900px). So for my use case I'll need something a bit different. Jotting a few potential thoughts down - maybe others have some better ideas:

  • Only regenerate the mipmap after all layers have been rendered for a single frame (probably still too expensive for this particular case but probably useful for other 3d render target use cases).
  • Copy texture data to a 2d render target to generate mipmaps and then copy the whole mip change to the target layer (only works for array texture targets).

@gkjohnson gkjohnson added this to the r170 milestone Oct 17, 2024
Copy link

github-actions bot commented Oct 17, 2024

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 690.67
171.1
690.8
171.12
+137 B
+20 B
WebGPU 816.43
220.08
816.43
220.08
+0 B
+0 B
WebGPU Nodes 815.94
219.95
815.94
219.95
+0 B
+0 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 463.31
111.89
463.45
111.9
+143 B
+12 B
WebGPU 538.61
145.41
538.61
145.41
+0 B
+0 B
WebGPU Nodes 494.73
135.28
494.73
135.28
+0 B
+0 B

@gkjohnson gkjohnson merged commit 29c41b6 into mrdoob:dev Oct 17, 2024
12 checks passed
@gkjohnson gkjohnson deleted the 3d-texture-mipmaps branch October 17, 2024 09:18
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.

WebGLRenderer: Mipmaps are not generated for WebGLArrayRenderTarget
2 participants