Skip to content

WebGLRenderer: Fixed readRenderTargetPixelsAsync checking readability against incorrect render target#30672

Merged
Mugen87 merged 3 commits into
mrdoob:devfrom
greyb1t:readRenderTargetPixelsAsync-rt-fix
Mar 7, 2025
Merged

WebGLRenderer: Fixed readRenderTargetPixelsAsync checking readability against incorrect render target#30672
Mugen87 merged 3 commits into
mrdoob:devfrom
greyb1t:readRenderTargetPixelsAsync-rt-fix

Conversation

@greyb1t

@greyb1t greyb1t commented Mar 6, 2025

Copy link
Copy Markdown
Contributor

Description

readRenderTargetPixelsAsync was checking if the render target was readable before binding the render target to active framebuffer.

This resulted in the texture readability check occurring on the previously set framebuffer and not the render target we are reading pixels from.

I modified the webgl_interactive_cubes_gpu example to restore the render target to the default before we call readRenderTargetPixelsAsync as that reproduces the issue without the fix.

EDIT: For some reason the file diff looks disgusting, please refer to the "Commits" tab instead of "Files changed" for better clarity on what changed.

greyb1t added 2 commits March 6, 2025 21:35
… against incorrect render target

readRenderTargetPixelsAsync was checking if the render target was readable before binding the render target to active framebuffer.

This resulted in the texture readability check occurring on the previously set framebuffer and not the render target we are reading pixels from.
@github-actions

github-actions Bot commented Mar 6, 2025

Copy link
Copy Markdown

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 336.02
78.26
336.02
78.26
+0 B
+1 B
WebGPU 523.84
145.45
523.84
145.45
+0 B
+0 B
WebGPU Nodes 523.31
145.34
523.31
145.34
+0 B
+0 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 465.06
112.14
465.06
112.14
+0 B
+1 B
WebGPU 594.24
161.05
594.24
161.05
+0 B
+0 B
WebGPU Nodes 549.37
150.49
549.37
150.49
+0 B
+0 B

@gkjohnson

Copy link
Copy Markdown
Collaborator

Thanks - the docs don't make it completely clear that the two gl enumerations are dependent on a bound framebuffer. Greggman's writeup on readpixels confirms it.

EDIT: For some reason the file diff looks disgusting, please refer to the "Commits" tab instead of "Files changed" for better clarity on what changed.

Looking at the diff without whitespace changes makes it easier to read. Add ?w=1 to the url.

@gkjohnson gkjohnson added this to the r175 milestone Mar 7, 2025
Comment thread examples/webgl_interactive_cubes_gpu.html
@Mugen87 Mugen87 merged commit 2e7fadc into mrdoob:dev Mar 7, 2025
@greyb1t greyb1t deleted the readRenderTargetPixelsAsync-rt-fix branch March 7, 2025 09:15
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.

3 participants