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

[3.x] Add maximum roughness cutoff to SSR to improve performance #56815

Open
wants to merge 1 commit into
base: 3.x
Choose a base branch
from

Conversation

Calinou
Copy link
Member

@Calinou Calinou commented Jan 15, 2022

3.x version of #56804.

In a test scene with mixed rough and non-rough materials, this saves 0.2 ms of GPU time with very little visual artifacting (GeForce RTX 4090, 3840×2160). This also incorporates the roughness fadeout from #69828, which can help hide visual artifacts on rough surfaces and generally make SSR look more stable.

The roughness cutoff can be adjusted in the Environment properties. Setting it to 1.0 will result in the previous behavior being used.
Edit (June 2023): This is no longer present for now. We need to discuss whether we should add this setting, as it's not in 4.x and probably won't be added there.

Testing project (3.x): test_ssr_performance-3.x.zip

Preview

No roughness cutoff (previous behavior)

before webp

Roughness cutoff = 0.7 (new default)

after webp

@Calinou Calinou requested review from a team as code owners January 15, 2022 16:12
@Calinou Calinou added this to the 3.5 milestone Jan 15, 2022
@Calinou Calinou changed the title Add maximum roughness cutoff to SSR to improve performance Add maximum roughness cutoff to SSR to improve performance (3.x) Jan 15, 2022
@akien-mga akien-mga modified the milestones: 3.5, 3.x Jul 3, 2022
Copy link
Member

@clayjohn clayjohn left a comment

Choose a reason for hiding this comment

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

I'm not sure if adding this to 3.x makes sense. This will add a sharp cutoff point where SSR will just disappear. In 4.0 the equivalent code was added after we added a smooth falloff to the SSR rough reflections so that SSR could gradually fade out on materials with a varying amount of roughness. A similar fade-out could be added here and then I guess it would be fine

drivers/gles3/shaders/screen_space_reflection.glsl Outdated Show resolved Hide resolved
@Calinou
Copy link
Member Author

Calinou commented Dec 15, 2022

A similar fade-out could be added here and then I guess it would be fine

Yes, I agree backporting both the fade-out and roughness cutoff makes sense. SSR looking too sharp and too present in 3.x is a common complaint after all, so better make it more subtle when it makes sense (and also faster at the same time).

In a test scene with mixed rough and non-rough materials, this saves
0.15-0.3 ms of GPU time with very little visual artifacting
(GTX 1080, 2560×1440).

The roughness cutoff can be adjusted in the Environment properties.
@Calinou Calinou force-pushed the ssr-add-max-roughness-cutoff-3.x branch from 04c27bc to 73bbc73 Compare June 27, 2023 09:02
@Calinou
Copy link
Member Author

Calinou commented Jun 27, 2023

Rebased and tested again, it works as expected. I've implemented @clayjohn's roughness cutoff from 4.x. However, this poses a challenge for the max_roughness setting, as the fadeout values don't depend on the roughness cutoff. I've tried min()/max()ing those with the max_roughness values, but it tends to look pretty bad in practice if you change the roughness cutoff from the default.

Screenshots in OP were updated to show the new visual and performance results.

@Calinou Calinou changed the title Add maximum roughness cutoff to SSR to improve performance (3.x) [3.x] Add maximum roughness cutoff to SSR to improve performance Jun 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants