Skip to content

Add GTAO shader support #8688

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

Merged
merged 38 commits into from
May 16, 2025
Merged

Add GTAO shader support #8688

merged 38 commits into from
May 16, 2025

Conversation

show50726
Copy link
Contributor

@show50726 show50726 commented May 1, 2025

Note: It has not been tested and benchmark on real devices yet.

  • Create gtao.mat and gtaoImpl.fs
  • Add an option to AmbientOcclusionOptions to select AO type
  • Add an additional GTAO struct to AmbientOcclusionOptions for GTAO specific parameters
  • Update PostProcessManager::screenSpaceAmbientOcclusion() to select different material based on the option and set the parameters
  • Update ViewerGui for GTAO parameters

Screenshots

I adjust the settings to make both SAO and GTAO using the similar sample count and take some screenshots.
Noted that SAO did some adjustments to the intensity and power params before passing into the material, so the effect looks stronger than GTAO under the same params.

SAO (original)

image
image

GTAO

image
image

@show50726 show50726 requested a review from pixelflinger May 1, 2025 15:32
@show50726
Copy link
Contributor Author

Will create another PR to update the remote webpage after this PR is in.

@pixelflinger pixelflinger added the internal Issue/PR does not affect clients label May 1, 2025
Copy link
Collaborator

@pixelflinger pixelflinger left a comment

Choose a reason for hiding this comment

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

I suspect that there will be issues with highp / mediump so, you definitely need to test this on real mobile device.

@show50726
Copy link
Contributor Author

show50726 commented May 7, 2025

Here is the on device profiling result:

  • Device: Pixel 7 Pro
  • Backend: OpenGL ES
  • App: sample-gltf-viewer.apk
  • Model: sponza.glb
  • GTAO settings:
    • Slice Count = 4
    • Steps Per Slice = 3
    • Low Pass Filter = Quality::HIGH
  • SAO settings:
    • All using default values, except for Quality

No Bent Normals

Method SAO (Quality::MEDIUM) SAO (Quality::HIGH) SAO (Quality::ULTRA) GTAO
SSAO Pass 5.865ms 8.074ms 14.383ms 11.579ms
Blur Pass 1.592ms 1.464ms 1.410ms 2.815ms
Total GPU Time 7.457ms 9.538ms 15.793ms 14.394ms

Bent Normals

Method SAO (Quality::MEDIUM) SAO (Quality::HIGH) SAO (Quality::ULTRA) GTAO
SSAO Pass 7.943ms 10.753ms 19.382ms 12.638ms
Blur Pass 2.40ms 2.402ms 1.584ms 4.911ms
Total GPU Time 10.343ms 13.155ms 20.966ms 17.549ms

So given this set of default parameters, I think the performance of GTAO is between SAO with Quality::HIGH and Quality::ULTRA. Also I did not see obvious artifact that is not shown on pc build.

@pixelflinger
Copy link
Collaborator

@show50726 how do you explain the performance difference of the blur pass? Shouldn't it be exactly the same?

@show50726
Copy link
Contributor Author

@show50726 how do you explain the performance difference of the blur pass? Shouldn't it be exactly the same?

Do you refer to the difference between SAO and GTAO? This is because I set Low Pass Filter = Quality::HIGH in GTAO.
The reason I do this is because I think GTAO should have this settings by default to have a better visual result or the artifacts would be more obvious.
According to the original paper, they do both spatial and temporal filtering to reduce the artifacts, but I think temporal filtering might be too expensive for us, so the alternative I do is to set the Low Pass Filter = Quality::HIGH. (I also mention this recommendation in the AmbientOcclusionOptions' comment )

@pixelflinger
Copy link
Collaborator

@show50726 how do you explain the performance difference of the blur pass? Shouldn't it be exactly the same?

Do you refer to the difference between SAO and GTAO? This is because I set Low Pass Filter = Quality::HIGH in GTAO.
The reason I do this is because I think GTAO should have this settings by default to have a better visual result or the artifacts would be more obvious.
According to the original paper, they do both spatial and temporal filtering to reduce the artifacts, but I think temporal filtering might be too expensive for us, so the alternative I do is to set the Low Pass Filter = Quality::HIGH. (I also mention this recommendation in the AmbientOcclusionOptions' comment )

I understand the reasoning, but I think it hurts the comparison. I think that's okay to leave the default to HIGH for GTAO, but In the table above I think they should both use HIGH then.

@pixelflinger pixelflinger self-requested a review May 14, 2025 16:51
@show50726
Copy link
Contributor Author

@show50726 how do you explain the performance difference of the blur pass? Shouldn't it be exactly the same?

Do you refer to the difference between SAO and GTAO? This is because I set Low Pass Filter = Quality::HIGH in GTAO.
The reason I do this is because I think GTAO should have this settings by default to have a better visual result or the artifacts would be more obvious.
According to the original paper, they do both spatial and temporal filtering to reduce the artifacts, but I think temporal filtering might be too expensive for us, so the alternative I do is to set the Low Pass Filter = Quality::HIGH. (I also mention this recommendation in the AmbientOcclusionOptions' comment )

I understand the reasoning, but I think it hurts the comparison. I think that's okay to leave the default to HIGH for GTAO, but In the table above I think they should both use HIGH then.

I agree what you say. I will do another profiling to make them all use Quality::HIGH.
I will hold this PR until I get the results.

@show50726 show50726 enabled auto-merge (squash) May 15, 2025 23:58
@show50726 show50726 merged commit fe474a9 into google:main May 16, 2025
12 checks passed
@show50726 show50726 deleted the dev/gtao branch May 20, 2025 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal Issue/PR does not affect clients
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants