-
-
Notifications
You must be signed in to change notification settings - Fork 19.5k
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
Fixing artifacts in SSR #66756
Fixing artifacts in SSR #66756
Conversation
When we look at the base of the cube we see a dark line where the cube meets the ground: This is caused by the fact that we are blurring our reflection texture. Where the cube hits the floor we either get no reflection, or we are reflecting the ground back into the cube (even though that data is not used). We need to improve the blur logic to at the very least ignore where we don't have reflections, but also find a way to isolate surfaces. Not sure yet how we're going to fix this (or if it can even be fixed). |
Maybe it'd be possible to dilate edges of the reflection buffer before blurring to avoid bleeding in black? Or alpha blend the unblurred version underneath the blurred one - that could be relatively cheap. It would not fix the issue completely but it'd patch the black edges with unblurred reflection. I guess it would be less visible? Of course this assumes the SSR buffer has alpha information that can be used for correctly blending the blurred edge without affecting anything else. |
Can AA be applied to SSR? |
#56844 should have fixed this when there's no blur, but maybe it's not done correctly or I didn't remove enough steps.
No, but SSR can be jittered every frame when TAA is enabled to smooth it out over time. This is what AAA games do 🙂 |
That would be nice to have |
It's the blur step that causes the lines because it blurs with either black from neighboring pixels where there is no reflection, or with the reflection on adjacent faces. |
Changes look good to me so far! |
@BastiaanOlij good to see this getting some attention, thanks for working on it. Is there any way of adding an option to isolate the SSR to just the ground plane or y up normals? In so many cases you only want reflections on floors/water/puddles etc, but end up getting lots of SSR artifacts on walls, small objects etc. where they are not desired. If such an option were possible, it may also be more performant? |
@fracteed that should be possible as a setting and indeed it would limit the pixels on which we're raymarching the reflection. Should be something for a separate PR though. |
The best way to solve this will be to move to Hi-Z tracing. It essentially allows us to trace much further with the same number of samples. Here is a detailed blog post explaining the method https://sugulee.wordpress.com/2021/01/19/screen-space-reflections-implementation-and-optimization-part-2-hi-z-tracing-method/. The original paper is very short and doesn't do a good job outlining the benefits over linear tracing. AFAIK Hi-Z tracing is the current popular method |
Using a roughness cutoff can help in this case: #56804 I suppose this is still relevant with Hi-Z tracing too, as it can be used to further improve performance in this case. |
Ya, Hi-z tracing just changes the ray-marching loop. It doesn't impact the other parts. So it is a drop-in replacement for what we are doing now. |
@clayjohn it looks like its a little more then that as we need to create mipmaps of the depth buffer. But it does look like a really sweet solution. |
Yes, but that won't be too challenging as we already generate mipmaps of the depth buffer for SSAO and SSIL and we can share them with SSR. |
Oh, so we could pretty much get the Hi-Z tracing optimization nearly for free? |
I don't know if I would say that. But there should be very little additional cost, so the performance benefit should far outweigh the cost. |
Thanks! |
This PR fixes :
Note that in the comments below I'm highlighting some of the different fixes, and highlight a few other issues I found that need further discussion and may need to be solved in further PRs.