-
-
Notifications
You must be signed in to change notification settings - Fork 35.8k
WebGLRenderer - Add MRT support to .readRenderTargetPixels() #31089
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
base: dev
Are you sure you want to change the base?
Conversation
…gets_read and use readRenderTargetPixels
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
src/renderers/WebGLRenderer.js
Outdated
*/ | ||
this.readRenderTargetPixels = function ( renderTarget, x, y, width, height, buffer, activeCubeFaceIndex ) { | ||
this.readRenderTargetPixels = function ( renderTarget, x, y, width, height, buffer, activeCubeFaceIndex, textureIndex ) { |
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.
Let's use a default parameter like in WebGPURenderer
so textureIndex = 0
.
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<title>three.js webgl - Multiple Render Targets Read Pixels</title> |
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.
Instead of creating a new example, do you mind enhancing webgl_read_float_buffer
instead?
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.
Sure, do you mean changing the target there to be with multiple textures or adding an option in the UI to switch between single and multiple?
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.
I think we can just use MRT.
Also do you prefer to keep the stackoverflow link as comment for the explanation, or should I remove it? |
Let's remove it. We just implement what the WebGL spec suggest so it should be clear what's going on. |
The example can be tried here - https://rawcdn.githack.com/PalashBansal96/three.js/read-mrt-2/examples/webgl_multiple_rendertargets_read.html |
Can we also update the Thanks for adding this! |
Oh right, I missed the Also, the signature of |
Let's focus on adding |
Fixes: #22403
Description
Adds support to read by texture index in
WebGLRenderer.readRenderTargetPixels
.For the test, duplicated the example
webgl_multiple_rendertargets
towebgl_multiple_rendertargets_read
and added readRenderTargetPixels on mouse position for both buffers. It can also be added to the same example to avoid duplication.This contribution is funded by ThreePipe