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: Added double-side transmission 2/2 #29718

Merged
merged 2 commits into from
Oct 21, 2024

Conversation

sunag
Copy link
Collaborator

@sunag sunag commented Oct 21, 2024

Related issue: #29705

Description

Renders all back-side first in case of materials with transmission and double-side. This would only be noticeable with many objects with this setup in the scene.

WebGPURenderer's approach, unlike WebGLRenderer, does not render opaque objects twice, and keeps the sequence of transparent materials with transmission in the same sort, which is also an improvement.

  1. Render opaques
  2. Render back-side transmission materials
  3. Render all transparents materials, for transmission only the front-side

Copy link

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 692.71
171.44
692.71
171.44
+0 B
+0 B
WebGPU 817.93
220.59
818.62
220.76
+692 B
+171 B
WebGPU Nodes 817.44
220.46
818.13
220.62
+692 B
+167 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Before After Diff
WebGL 464.93
112.2
464.93
112.2
+0 B
+0 B
WebGPU 538.86
145.56
539.55
145.72
+692 B
+166 B
WebGPU Nodes 494.86
135.37
495.55
135.53
+692 B
+163 B

@sunag sunag added this to the r170 milestone Oct 21, 2024
@sunag sunag marked this pull request as ready for review October 21, 2024 16:01
@sunag sunag merged commit 4c36f5f into mrdoob:dev Oct 21, 2024
12 checks passed
@sunag sunag deleted the dev-double-renderList branch October 21, 2024 17:36
@hybridherbst
Copy link
Contributor

@sunag a bit of a tangent here, but while you're in this part of the codebase: would it be possible to render transmissive objects that have transmission=1 and ior=1 with a regular transparent pass? This would improve performance on weaker devices (e.g. Quest 2/3) for the most typical case of "clear glass", which currently often needs to be emulated with opacity, since transmission always introduces a fullscreen pass at a big performance penalty.

@sunag
Copy link
Collaborator Author

sunag commented Oct 21, 2024

I think we can have barriers with normalmaps and other settings that influence the color in transmission and other validations that will have to be tested each frame, and animation, I would recommend creating a routine to replace the material if possible?

The new architecture does not do a full-screen pass, but a copy of the current buffer to a texture, which is much faster regardless of the backend used.

One possible next step for performance would be to use hashed blur and avoid generating mipmaps.

@hybridherbst
Copy link
Contributor

hybridherbst commented Oct 22, 2024

Thanks!

a copy of the current buffer to a texture, which is much faster regardless of the backend used

I'm not sure this holds in practice on tiled GPUs – At least in my understanding, "no copy" will always be faster than "screen-space copy".

replace the material if possible

With what? I'm not aware of a good way to emulate how transmission is supposed to look without using transmission...

@sunag
Copy link
Collaborator Author

sunag commented Oct 22, 2024

Transmission without the framebuffer texture is not transmission anymore, I think your idea was to emulate it with opacity?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants