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

Examples: Simplify composer setup in GTAO demo. #27319

Merged
merged 3 commits into from
Dec 5, 2023
Merged

Conversation

Mugen87
Copy link
Collaborator

@Mugen87 Mugen87 commented Dec 5, 2023

Related issue: #27317

Description

@Rabbid76 This PR simplifies the composer setup by not using MSAA and also rendering with the native resolution instead.

Ideally, user should not setup the render target for the composer manually. Besides, MSAA is not the best AA technique for (HDR) FX workflows. Yes, the demo does not use HDR but I suppose many users will use GTAOPass with a HDR workflow. Probably better to promote something different (like TAA or SMAA/FXAA) depending on the use case.

@Mugen87 Mugen87 added this to the r160 milestone Dec 5, 2023
@Rabbid76
Copy link
Contributor

Rabbid76 commented Dec 5, 2023

@Mugen87 small change, impressive impact ���

@Mugen87
Copy link
Collaborator Author

Mugen87 commented Dec 5, 2023

The new demo runs at 60 FPS on my M2 Pro but on a Pixel 4a it runs with 10 FPS^^.

Lower frame rates with low/mid end mobile devices are not surprising. I just wonder if we should keep the example as it is so we have more usable results on a greater variety of devices.

@Mugen87
Copy link
Collaborator Author

Mugen87 commented Dec 5, 2023

I think rendering such effects in full native resolution is tricky on mobile devices. Projects have to compute the AO (and other effects) with smaller resolutions in order to avoid fragment-shader bound apps. For now, I don't add the device pixel ration for a better compromise of performance and quality.

@Mugen87 Mugen87 merged commit 5fbea0b into mrdoob:dev Dec 5, 2023
10 checks passed
@Rabbid76
Copy link
Contributor

Rabbid76 commented Dec 5, 2023

An AO algorithm is simply an approximation to an integral over a hemisphere. There are different algorithms, some are fast and give poor results, others are slower and give better results. GTAO belongs to the second category. None of the algorithms is ideal and all have advantages and disadvantages.

@Mugen87
Copy link
Collaborator Author

Mugen87 commented Dec 5, 2023

Indeed. Against this backdrop it might make sense to keep SSAO which is the fastest of SSAOPass, SAOPass and GTAOPass according to my first tests. However, it also provides the worst results.

We maybe can ditch SAOPass in the future since it is seems more expensive than GTAO and there are some quality issues in its example. It seems the effect tends to darken occluded areas too strong so they become almost black. Can't tell yet if this is okay...

@Mugen87
Copy link
Collaborator Author

Mugen87 commented Dec 5, 2023

@Rabbid76 If you have the opportunity, it would be great if you could test the new demo with a mobile device. I have noticed some artifacts on the loaded asset when you zoom out. It's hard to describe but it looks like black/shadowed stripes that are present on the entire asset (see screenshot). The also depend on what camera angle you look at the scene. The go away if you zoom closer into the scene.

Screenshot_20231205-170528

@Rabbid76
Copy link
Contributor

Rabbid76 commented Dec 5, 2023

@Mugen87 I will have a look. The issue seems to be related to the sample distribution of the gtao and/or denoiser. Or the device resolution is simply not set correctly somewhere. Fortunately, there are still a few days until the next release.

@Mugen87
Copy link
Collaborator Author

Mugen87 commented Dec 5, 2023

No need to rush. 👍

The result of the pass is already impressive! Can't believe how good the AO has looked in the 5K rendering^^.

@Rabbid76
Copy link
Contributor

Rabbid76 commented Dec 5, 2023

Did some tests. Seems to be an issue with the depth buffer. AO only (no Denoise):

Screenshot_20231205_192901_Chrome

@Mugen87
Copy link
Collaborator Author

Mugen87 commented Dec 5, 2023

The depth precision of UnsignedIntType is >= 16 bits. On desktop, the value is usually higher but on mobile it could be indeed 16 bits which is too low. I think we can try this in setGBuffer():

this.depthTexture.format = DepthStencilFormat;
this.depthTexture.type = UnsignedInt248Type;

In this way, we definitely get 24 bits. That should be sufficient.

@Mugen87
Copy link
Collaborator Author

Mugen87 commented Dec 5, 2023

Um, that did not seem to help. Still getting the issue with a Pixel 4a.

@Rabbid76
Copy link
Contributor

Rabbid76 commented Dec 5, 2023

Yep, still the same. I will investigate this further...

@Mugen87
Copy link
Collaborator Author

Mugen87 commented Dec 5, 2023

Respective PR #27320. The trick is using highp for the depth samplers.

@Rabbid76
Copy link
Contributor

Rabbid76 commented Dec 5, 2023

Solved! Thank you so much! ❤️

@Mugen87
Copy link
Collaborator Author

Mugen87 commented Dec 5, 2023

Awesome! BTW, with the default composer setup (without MSAA), the GTAO runs at 60 FPS on my Pixel 4a now 👍 .

AdaRoseCannon pushed a commit to AdaRoseCannon/three.js that referenced this pull request Jan 15, 2024
* Examples: Simplify composer setup in GTAO demo.

* Examples: Update screenshots.

* Examples: More clean up.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants