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

WebGLRenderer: Add transmission render target scale #30018

Merged
merged 4 commits into from
Dec 9, 2024
Merged

Conversation

michaeldll
Copy link
Contributor

@michaeldll michaeldll commented Dec 2, 2024

Fixed #30017.

Description

By default, the transmission render target takes up the full viewport. Reducing this render target size is valuable due to the considerable performance impact of rendering at full resolution and minimal visual degradation by just scaling the transmission render target size.

Here is a quick side-by-side comparison of full scale versus 33% scale, respectively:

100-Screenshot 2024-12-02 at 20 20 59 33-Screenshot 2024-12-02 at 20 20 38

Copy link

github-actions bot commented Dec 2, 2024

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 339.11
78.98
339.2
79.01
+95 B
+23 B
WebGPU 486.01
134.92
486.01
134.92
+0 B
+0 B
WebGPU Nodes 485.48
134.83
485.48
134.83
+0 B
+0 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 465
112.04
465.1
112.06
+95 B
+24 B
WebGPU 555.41
150.39
555.41
150.39
+0 B
+0 B
WebGPU Nodes 511.26
140.1
511.26
140.1
+0 B
+0 B

@michaeldll
Copy link
Contributor Author

michaeldll commented Dec 2, 2024

I realized that I have done this directly on the dev branch instead of making my own by mistake. Let me know if this is fixable or if I should open another PR instead. Sorry about that.

@Mugen87
Copy link
Collaborator

Mugen87 commented Dec 2, 2024

Yes, I think a scale factor for transmission makes sense. Depending on the device, using the full resolution is quite taxing.

I realized that I have done this directly on the dev branch instead of making my own by mistake.

That is not an issue.

@@ -193,6 +193,9 @@ class WebGLRenderer {
let _clippingEnabled = false;
let _localClippingEnabled = false;

// transmission render target scale
this.transmissionRenderTargetScale = 1.0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mind documenting this new property here: https://threejs.org/docs/index.html#api/en/renderers/WebGLRenderer

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, let me know if the wording is clear enough.

@michaeldll michaeldll requested a review from Mugen87 December 6, 2024 09:17
@Mugen87
Copy link
Collaborator

Mugen87 commented Dec 6, 2024

The PR looks good to me!

Having the ability to scale the transmission render target resolution is indeed useful. When I remember correctly from earlier discussions, there were reservations to add such properties to the renderer interface. However, since the transmission render target is global we can't use a material setting. So I think the solution here is fine.

@Mugen87 Mugen87 added this to the r172 milestone Dec 7, 2024
@Makio64
Copy link
Contributor

Makio64 commented Dec 8, 2024

@michaeldll can you add this ability in one example using transmission so it's easy to find for new comers ?

ps : thanks for this pr, very useful for mobile and low power device!

@michaeldll
Copy link
Contributor Author

@Makio64 Good call, just added it to webgl_materials_physical_transmission:

Screen.Recording.2024-12-08.at.11.25.14.mp4

@Mugen87 Mugen87 merged commit ef48dee into mrdoob:dev Dec 9, 2024
12 checks passed
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.

Add transmission render target scale for performance improvements
3 participants