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: MSAA, Postprocessing and Wireframe support in the WebGL Backend #27473

Merged
merged 16 commits into from
Jan 3, 2024

Conversation

RenaudRohlinger
Copy link
Collaborator

@RenaudRohlinger RenaudRohlinger commented Dec 30, 2023

Happy New Year!!

Multiple points are addressed in this PR:

Live example MSAA:
webgpu_multisampled_renderbuffers

Live example Postprocessing:

image

This contribution is funded by Utsubo

@RenaudRohlinger RenaudRohlinger changed the title WebGPURenderer: Support Material Wireframe in WebGLBackend Dec 30, 2023
@sunag sunag added this to the r161 milestone Dec 30, 2023
@RenaudRohlinger
Copy link
Collaborator Author

RenaudRohlinger commented Dec 31, 2023

Added to this PR some fixes notably #27466, and MSAA support and a new webgpu example that combine all this (webgpu_multisampled_renderbuffers).

I have other points I would like to improve but I will wait on #27463 to be merged to cleanup and move textures related methods to WebGLTextureUtils.

@RenaudRohlinger RenaudRohlinger changed the title WebGPURenderer: Support Material Wireframe in the WebGL Backend Dec 31, 2023
@RenaudRohlinger
Copy link
Collaborator Author

Cleaned up a bit more the code and made some space and improvement for another issue I wanted to fix (postprocessing support in the WebGL backend).

I'm still struggling with a feedback loop issue from the WebGL Backend when multiple framebuffers are involved (which is currently an issue in the dev branch):
WebGL warning: drawArraysInstanced: Texture level 0 would be read by TEXTURE_2D unit 0, but written by framebuffer attachment COLOR_ATTACHMENT0, which would be illegal feedback.

Not sure how I should update the pipeline there and where to unbind the previous RTT which is then attached as a texture to next one. But maybe we could merge this PR before it grows even larger.

/cc @sunag

@RenaudRohlinger
Copy link
Collaborator Author

RenaudRohlinger commented Jan 2, 2024

Nevermind, I just found how to support for postprocessing. I will re-request review when it's ready I need to test all the examples. /cc @sunag 😄

@RenaudRohlinger RenaudRohlinger changed the title WebGPURenderer: MSAA, Wireframe Support in WebGL Backend and Fixes Jan 2, 2024
@RenaudRohlinger
Copy link
Collaborator Author

RenaudRohlinger commented Jan 3, 2024

Added support for multipass in the postprocessing pipeline and removed the WebGPU condition in 2 new demos:

Live example here:

I'm currently re-binding the framebuffer per render object in the draw method of the WebGLBackend.
This solution is not final as it requires each quad in the RTT pipeline to be in the same configuration (size and so on), the issue is that currently all the renderTarget setup is configured at the very beginning of Renderer.render(), but then if there is multiple pass in the pipeline each FBO will have its own renderContext. Without re-binding the framebuffer they will all inherit only of the configuration of the first renderContext called at the very beginning of render() which is not good. /cc @sunag

I think there could be a better solution which might require a refactor in the Renderer class which will impact the WebGPU side so I'd rather not touch it in this PR.

I'm satisfied of the current state of this. I will stop there and create new PRs once this one is merged.

@sunag
Copy link
Collaborator

sunag commented Jan 3, 2024

I think beginRender() and finishRender could dealing with the re-binding of framebuffer, perhaps related to renderContextData.previousContext, the previous context information may be lost if it is called in a more than once in the same flow of Node.updateBefore maybe it can be related with re-bind in the draw. But I'm also in favor of checking this more calmly in other PR. Amazing progress you did these days!

@sunag sunag merged commit aeb40de into mrdoob:dev Jan 3, 2024
11 checks passed
AdaRoseCannon pushed a commit to AdaRoseCannon/three.js that referenced this pull request Jan 15, 2024
…GL Backend (mrdoob#27473)

* support material.wireframe in webgl backend

* fix reattach framebuffer, support msaa and wireframe demo

* fix depth samples === 0

* cleanup

* more cleanup

* more cleanup to the webgl pipeline

* postprocessing support

* fix msaa

* fix example afterimage

* improved state management and performances

* generate a new webgl slot for fbos

* revert puppeteer

* fix copyFrameBufferToTexture with correct unbinding and cleanup

* fix multipass pipeline in webgl backend and enable new demos

* regenerate screenshot with gaussian blur
@Methuselah96 Methuselah96 mentioned this pull request Jan 16, 2024
45 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants