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

WebGPURenderer: Allow specifying texture index for MRT in readRenderTargetPixelsAsync(). #28197

Merged
merged 2 commits into from
Apr 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/jsm/renderers/common/Renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1086,9 +1086,9 @@ class Renderer {
}


readRenderTargetPixelsAsync( renderTarget, x, y, width, height ) {
readRenderTargetPixelsAsync( renderTarget, x, y, width, height, index = 0 ) {

return this.backend.copyTextureToBuffer( renderTarget.texture, x, y, width, height );
return this.backend.copyTextureToBuffer( renderTarget.textures[ index ], x, y, width, height );
Copy link
Collaborator

@Mugen87 Mugen87 Apr 23, 2024

Choose a reason for hiding this comment

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

Does this code...actually work? At least the WebGL backend won't work until gl.readBuffer() is used in WebGLTextureUtils.copyTextureToBuffer().

I'm not sure about required workflow in WebGPU. Do you mind demonstrating the updated method with an example? E.g. you could use the code from https://threejs.org/examples/webgpu_multiple_rendertargets but instead of rendering to the screen, you extract (color and normal) values via readRenderTargetPixelsAsync().


}

Expand Down