godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.84k stars 21.14k forks source link

SSAO and SSIL Break with Odd Resolutions #73697

Open mrjustaguy opened 1 year ago

mrjustaguy commented 1 year ago

Godot version

4.0 rc 3

System information

Windows 11, Vulkan, GTX 1050 Ti 528.24

Issue description

SSAO/SSIL at full Res breaks when using Non-Even Resolutions (Half res works just fine)

image

Steps to reproduce

Set Viewport to Non-Even Resolution and Disable Half Size, and look at a Plane from a distance

Minimal reproduction project

N/A

ghost commented 1 year ago

I also get these beautiful ones. They disappear when SSIL is off. Is this the same issue, a known one, or should I report it? 2023-02-21

Calinou commented 1 year ago

I also get these beautiful ones. They disappear when SSIL is off. Is this the same issue, a known one, or should I report it? 2023-02-21

This appears to be the same as https://github.com/godotengine/godot/issues/56724.

mrjustaguy commented 1 year ago

This issue has not been solved in RC6, just heavily mitigated, odd resolutions still cause SSAO/SSIL at full res to produce streaking artifacts similar to OP, just much weaker and more centered around the middle of the screen.

image

BastiaanOlij commented 1 year ago

This one is really starting to do our heads in :) Talking to clay about how we could finally put this to bed but we really need some solid MRP for this as we fix one thing and another problem returns that doesn't show up in the tests we're using.

Talking with @clayjohn about this but the zest of my theory is as follows:

The root problem here is that we're slicing the screen into 4 for each effects buffer for performance reasons. So say as a worst case example a screen resolution of 999x599 becomes 4 times 250x150 (of 125x75 at half resolution).

The original problem causing the weird artifacts in the border were caused because the way the sizes are calculated resulted that we were only populating at a resolution of 249x149 ending up with only calculating data for 996x596 of the image, leaving a border of 4 pixels at the bottom and right side of the image with whatever data was there before. You start to notice issues especially when resizing as the data there will be left overs from other textures freed up and totally not suitable for what we're doing.

So that was fixed ensuring that we render to the full 250x150 resolution of each slice, the problem now is that our effects buffers have a total screen size of 1000x600, one pixel to many, I suspect that the streaking is caused because some of the processes will stretch the source image by 1 extra pixel, while others just see the extra pixel as outside of the source image.

The effect is worsened if you run SSAO at half size and SSIL at full size, or vise versa, because of the way we calculate size that way where I think we do a rounding that no longer matches the buffer size which is now the first mip of the full size.

Still trying to figure out how best to fix this.

mrjustaguy commented 1 year ago

Problem here is that it's not something that one can make a good MRP for, as camera positions, and viewport resolutions matter, and fixing one part likely breaks some other scenario.

Weird part is Half size is perfectly fine right now consistently.

MineBill commented 1 year ago

I've encountered this problem with SSAO and SSR (and SSIL i think). However, in my case, it only happens when MSAA 3D 2x is enabled (4x and 8x work ok). Since no one else has mentioned MSAA in any of the linked issues, i'm wondering if it's something different and i should open a new issue with a MRP and more info.

mrjustaguy commented 1 year ago

It is a different issue, there have been reports with corruption with MSAA and some screen space effects, on AMD Polaris for example.

I haven't encountered any issues like this with SSR, only SSAO and SSIL (which are using the same underlying logic more or less)