-
-
Notifications
You must be signed in to change notification settings - Fork 35.8k
WebGPURenderer: Make MSAA with MRT work with WebGL backend. #31228
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
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
for ( let i = 0; i < textures.length; i ++ ) { | ||
|
||
const { textureGPU } = this.get( textures[ i ] ); | ||
|
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.
Not sure but I think you should bind the MSAA FBO and the FBO here @Mugen87:
state.bindFramebuffer( _gl.FRAMEBUFFER, msaaFrameBuffer);
gl.framebufferRenderbuffer( gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT0 + i, gl.RENDERBUFFER, msaaRenderbuffers[ i ] );
state.bindFramebuffer( _gl.FRAMEBUFFER, fb);
gl.framebufferTexture2D( gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0 + i, gl.TEXTURE_2D, textureGPU, 0 );
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.
also unbind before the loop:
state.bindFramebuffer( _gl.READ_FRAMEBUFFER, null );
state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, null );
and rebind after:
state.bindFramebuffer( gl.READ_FRAMEBUFFER, msaaFrameBuffer );
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.
Unfortunately, that does not do any difference. In fact, it seems some bindings in WebGLRenderer
are redundant. A single bind of the draw and read buffer at the beginning of the blit process should be sufficinet. Removing all these bindings in WebGLRenderer
does not break webgl_multiple_rendertargets
.
Could this be that you're trying to read from the renderbuffers or before they're resolved to textures? |
@Mugen87 did you figure it out? I'm debugging with renderdoc to see where things go wrong but if you already solved it, I can stop. |
10 minutes ago I found out a missing call of When I understand the WebGL spec correctly, whatever you do with |
In any event, thanks for support! The hint with the renderbuffers was a good starting point. If all works, I think we can back-port part of this implementation to |
Fixed #30995.
Description
The PR tries to make the combination of MSAA and MRT work for the WebGL backend.
Unfortunately, the combination only works for the first attachment so far. I don't understand why additional attachments are not properly blit although the WebGL backend uses the same approach like in
WebGLRenderer
. The problem can be reproduced with below example (it always runs with the WebGL backend for testing).https://rawcdn.githack.com/Mugen87/three.js/c4d55169b9dc56732cf43e5143cd31226a6d5c8e/examples/webgpu_mrt.html
The expected result looks like so: https://threejs.org/examples/webgpu_mrt
@RenaudRohlinger Since you have implemented the initial support in
WebGLRenderer
, did you ever encounter such a problem?@cabanier I do not see any WebGL warnings in the browser console but do you see an obvious flaw in the framebuffer setup? I'm a bit out of ideas at the moment why the blit works partially but without reporting errors. A fresh pair of eyes would help^^.
The PR only implements the resolve. The setup of MSAA render buffers for each attachment has already been implemented by #27473.
three.js/src/renderers/webgl-fallback/WebGLBackend.js
Lines 2236 to 2295 in c7b6f81