-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
WebGLMultipleRenderTargets: Add multisampling support. #24001
Conversation
[WebGLMultipleRenderTarget] Support Multisampling clean bufferattributes code clean bufferattributes code
renderTarget.depthTexture = new THREE.DepthTexture( 512, 512 ); | ||
renderTarget.depthTexture.type = THREE.FloatType; |
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 don't see this used in the example anywhere. Just testing depth/stencil attachments?
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.
When using MRT in threejs that is the only way to get a proper depth buffer, otherwise you will get weird behaviors when two geometries overlap 🤷
Can also reproduce the black screen issue on iOS, but if you toggle multisampling off/on again, you can see that the textures aren't correctly re-populated via blit. This isn't present in my previous WebGL 2 example (#23300 (comment)), so we must be going wrong somewhere. |
I wonder why the E2E test fails. The screenshot in the PR looks as expected... |
Ideally, this PR is also tested on a Oculus Quest 2 since it affects its multisampling code path. |
Ah, maybe it's because I pushed two different versions of the screenshot? "ERROR! Diff wrong in 0.521 of pixels in file: webgl2_multiple_rendertargets_multisampled" EDIT: Seems to be fixed |
Ran through the WebXR examples (ball shooter, hands, layers) on my Quest 2 without issue. Issues in iOS Safari are still evident. Tried digging locally and everything looks correct as far as the changes. Notably, textures appear to retain color passed to |
We tried with WebXR and I can confirm that everything seems to work fine.
@CodyJasonBennett Are you sure that it is correctly working on your example and just a fortunate configuration? I wonder if you try to add a loop or a slightly more complex setup. I would suspect a Metal WebGL issue. |
I've tried toggling mipmaps and disabling everything that didn't deal with color attachments to compare with the blit method here https://gist.github.com/CodyJasonBennett/edbc4372d3c9a921ebc3e46cb5899ba8. Both this and the simplified demo appear to work. I'm not sure how to verify whether the multi-sampled render buffers are populated after render either, but I found it peculiar that they seemingly have no color output (blit appears to be copying everything correctly). |
Tested the PR a bit more on a Pixel 4a and macOS. Looking good so far 👍 . I have currently no iOS device at hand so I can't investigate the mentioned black screen. |
If it's possible to reproduce the issue with a plain, minimalistic WebGL example (so without three.js), one could report the issue at the WebKit bugtracker. BTW: An example with |
@Mugen87 I see, I will try to make a basic reproduction another time and submit it to WebKit bugtracker. In my opinion, this PR is now ready to merge. CI is ok, it does not change the previous behavior for MSAA anymore and works on all recent browsers 👍 |
Great! Can you then please remove the build files from the PR? |
Done! |
Create `DepthTexture` without parameters.
cool! The demo looks good |
Can this pr be merged in r141? Or there is something else to do? |
@ligaofeng0901 In my opinion everything is ready to be merged and this PR does not introduce any change except enhancement. In our company, we've been using it in production for 2 weeks and had no issues reported 👍 |
Thanks! |
Is it me or the MRT + multisample example is way laggier now? Even with samples set to 1. |
I used stencil buffer instead of a float depth texture to have a more precise quality. Using back float depth texture might be the solution 🤔 |
@marcofugaro Maybe the previous version that was using temporary FBO dedicated for the MRT Multisample was better? The new one was introduced to prevent the usage of temporary FBO but might be heavier indeed.3ba011d#diff-6bdac4da85be606f09e2ab24b41c761b23ced0d9acaa720e2f2200d938a714e9R1745-R1759 |
@jcyuan You should try |
solved! it was a mistake by re-use FBOs, i created 2 FBOs for 4 RTs. |
* setUsage does not update attributes after the buffer is created * check is not necessary in the buffer creation * clean code * prevent unnecessary double buffer update * fix lint * [WebGLMultipleRenderTarget] Support Multisampling [WebGLMultipleRenderTarget] Support Multisampling clean bufferattributes code clean bufferattributes code * removed unused code * added build for tests * pupeeter screenshot * better example * resets the active FBO back to the multisampled FBO after blitting. * lint * use mask instead of COLOR_BUFFER_BIT * Update webgl2_multiple_rendertargets_multisampled.html * wip fix safari * removed use of temporary buffers and fix safari and ios example * fix lint * fix pupeeter example? * prevent unecessary fbo creation for non-mrt * fix * fix puppeeter rendering black screenshot * remove build * Update webgl2_multiple_rendertargets_multisampled.html Create `DepthTexture` without parameters. * remove unecessary framebuffer render and texture instructions * example: usage of stencil buffer instead of depth texture Co-authored-by: Michael Herzog <[email protected]>
OMG So amazing! Any document about this implement? Confused Why ? @RenaudRohlinger |
@prophetw Just like a WebGLRenderTarget you have to use the samples property: renderTarget = new THREE.WebGLMultipleRenderTargets(
window.innerWidth * window.devicePixelRatio,
window.innerHeight * window.devicePixelRatio,
2,
{
samples: 4
}
);
// or renderTarget.samples = 4 Here the official example: |
I will cancel with pleasure
…On Tue, Jul 25, 2023 at 11:41 AM Prophet ***@***.***> wrote:
OMG So amazing! Any document about this implement? Confused Why ?
@RenaudRohlinger <https://github.com/RenaudRohlinger>
—
Reply to this email directly, view it on GitHub
<#24001 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BBMJAQSWUHNGUGXZPGPENYLXR55SPANCNFSM5U6O4ABA>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
I investigated MSAA MRT FBO, and got a result that WebGL2 may only support one Color_ATTACHMENT copy(blitFramebuffer). |
And i found a issue |
See #26143. This only affects D3Dx via ANGLE which is software emulated here. |
Fixed #23300
Description
Added multisampling support for WebGLMultipleRenderTargets.
Example (build is included in order to run the example):
This contribution is funded by Utsubo