-
-
Notifications
You must be signed in to change notification settings - Fork 35.8k
Renderer: Add MRT support to .readRenderTargetPixels(). #22403
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
Comments
I'm afraid this workflow is not supported. Extracting pixels from MRT color buffers requires the usage of gl.readBuffer() which is not used by the engine so far. For now, try to implement a custom function based on: shrekshao/MoveWebGL1EngineToWebGL2#4 (comment) |
Yeah, the approach mentaioned in the link solved my problem, thanks a lot ! |
This issue should also honor |
I see that here an attempt is also being made to read back float32 values and, as far as I have seen in the code, this is not supported. When using Float32Array only zeros are returned. Uint8Array must be used for readRenderTargetPixels. However, if a float32 value is to be consciously read back here, then I recommend renaming the issue. @Mugen87 have you merged the small extension I made for readRenderTargetPixelsAsync in #28180 into r164 or should I? I can do it if you wish. |
@Spiri0 Feel free to make a PR! |
If this is just about reading out multiple render targets then that would be done now. |
We still need adding support in @Spiri0 Since you are already into the topic, are you interested in giving it a shot? 😇 |
I can take a look at that. There is an analogous example in WebGL about multiple render targets. readRenderTargetPixels in WebGL works significantly differently than readRenderTargetPixelsAsync but I'm trying. I'll take a look at it today |
Describe the bug
I used WebGLMultipleRenderTargets to output several textures , then I set one of these textures to WebGLRenderTarget's texture,
then I passed these WebGLRenderTexture to WebGLRenderer.readRenderTargetPixels to get one pixel’value, but I only got (0,0,0,0) from the Float32Array I have passed
To Reproduce
Steps to reproduce the behavior:
1、if "rt" is a WebGLRenderTarget, setRenderTarget to "rt", eg. renderer.setRenderTarget(rt);
2、render something to it;
3、if I have another WebglRenderTarget "rt2", rt2.setTexture(rt.texture);
4、const read = new Float32Array( 4 );renderer.readRenderTargetPixels( rt2,posX, posY, 1, 1, new Float32Array( 4 ) );
or you can copy following code to three.js/examples/webgl_read_float_buffer.html, and replace the script part. I have only changed a small of them
Code
Live example
no live example,I cann't visit these links
Expected behavior
I hope I can get a effective value from the ArrayBufferView object, rather than 0.
Screenshots
Platform:
The text was updated successfully, but these errors were encountered: