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] Fix SSAO stairstepping artifacts when using a high Camera Far property #53784

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

Conversation

Calinou
Copy link
Member

@Calinou Calinou commented Oct 13, 2021

This matches master behavior where high Camera Far property values can be used just fine with SSAO.

This closes #42390.

Testing project: test_ssao_2_3.x.zip

Preview

Camera Far 100 (project default in 3.x)

Before After
ssao_old_far_100 ssao_new2_far_100

Camera Far 500 (editor default in 3.x)

Before After
ssao_old_far_500 ssao_new2_far_500

Camera Far 4,000 (default for both project and editor in master)

Before After
ssao_old_far_4000 ssao_new2_far_4000

This matches `master` behavior where high Camera Far properties
can be used just fine with SSAO.
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 don't think this is the right approach. What will happen with this change is that the depth buffer will be treated as if it is only 200 units deep (even if it is representing a scene that is 4000 units deep) so to the SSAO objects that are 1000 units apart will look like they are only 50 units apart. More concerningly, objects that are 20 units apart will cast SSAO as if they are one unit apart.

If you want to clamp distant SSAO, you should copy the approach used in ASSAO which is to fade the SSAO out as it approaches the maximum distance (which is configurable with a project setting)

float fade_out = clamp(pix_center_pos.z * params.fade_out_mul + params.fade_out_add, 0.0, 1.0);

@Calinou
Copy link
Member Author

Calinou commented Oct 14, 2021

If you want to clamp distant SSAO, you should copy the approach used in ASSAO which is to fade the SSAO out as it approaches the maximum distance (which is configurable with a project setting)

I don't think this will resolve the stairstepping artifacts that appear close to the camera though (especially when approaching a surface that's parallel to the camera). It's likely caused by a lack of depth buffer precision.

Can we do both approaches here (fade distant SSAO and limit camera Z far)?

@clayjohn
Copy link
Member

I don't think this will resolve the stairstepping artifacts that appear close to the camera though (especially when approaching a surface that's parallel to the camera). It's likely caused by a lack of depth buffer precision.
Can we do both approaches here (fade distant SSAO and limit camera Z far)?

Perhaps. We can't control the depth buffer precision, because that is set elsewhere. But maybe doing a combined approach can work to reduce the depth precision artifacts while also reducing the artifacts that come from arbitrarily scaling the depth values.

What is the highest Z-far we can use without introducing the stair stepping artifacts? I am thinking it you set the max Z-far to something like 2000 then the scaling artifacts should be minimal.

@Calinou
Copy link
Member Author

Calinou commented Oct 14, 2021

What is the highest Z-far we can use without introducing the stair stepping artifacts? I am thinking it you set the max Z-far to something like 2000 then the scaling artifacts should be minimal.

I already get significant artifacts when up close at Z-far = 1000. I'd say 500 is the maximum value where it's acceptable, but you can still notice artifacts if you look for them (compared to 200).

@akien-mga akien-mga modified the milestones: 3.4, 3.5 Nov 8, 2021
@akien-mga akien-mga modified the milestones: 3.5, 3.x Jul 3, 2022
@Calinou Calinou changed the title Fix SSAO stairstepping artifacts when using a high Camera Far property [3.x] Fix SSAO stairstepping artifacts when using a high Camera Far property 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.

None yet

3 participants