godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.07k stars 69 forks source link

Add a depth blend to the `3.x` SSAO effect to prevent SSAO from getting too dark when up close #3720

Open Riordan-DC opened 2 years ago

Riordan-DC commented 2 years ago

Describe the project you are working on

I am working on an FPS game. SSAO is a nice way for me to enhance the aesthetics of my game and make edges visible. As an FPS game the player camera is often very close to geometry.

Describe the problem or limitation you are having in your project

SSAO is applied as post processing with little regard for how a scene is viewed. In the current implementation of SSAO if you get really close to a spot where SSAO is applied it gets messy. It can easily detract from the experience. The current way to avoid this is by reducing intensity of the SSAO but this means you cannot take full advantage of SSAO in your project.

You can notice that this feature is in halo reach, Bungie only used SSAO within a range so you dont get gross SSAO up close or far away.

Notice below the noticeable SSAO artefacts aaaa

Describe the feature / enhancement and how it helps to overcome the problem or limitation

In the world environment editor the SSAO settings may have two extra sliders representing the depth (in godot units) when the SSAO starts and ends.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

In the godot rendering shader when SSAO is applied we can sample from the depth buffer and fade the affect in and out based on the parameters set above. I dont believe this would be an expensive operation or one that touches much code.

If this enhancement will not be used often, can it be worked around with a few lines of script?

Change SSAO behavior requires changing the engines main rendering shader which cannot be done with a script.

Is there a reason why this should be core and not an add-on in the asset library?

As mentioned above this requires changing the godot shader source and cannot be patched with any script or native lib as far as I am concerned.

mrjustaguy commented 2 years ago

This exists in 4.0, in Project Settings. it's called something like Fade Start and Fade End. Not sure about 3.x tho, as they are using different implementations.

Calinou commented 2 years ago

This is already fixed with the new SSAO implementation in the master branch (ASSAO). However, ASSAO cannot be backported to 3.x due to its reliance on compute shaders. In 3.x, implementing GTAO would be the best way to resolve this issue, but it's expensive at high settings.

There is also a pull request that implements a maximum SSAO darkening property in Environment. You could use this as a stop-gap solution by recompiling your editor and export template binaries with that change included.

Riordan-DC commented 2 years ago

Great responses, ill close this issue.

clayjohn commented 2 years ago

However, ASSAO cannot be backported to 3.x due to its reliance on compute shaders. In 3.x, implementing GTAO would be the best way to resolve this issue, but it's expensive at high settings.

To clarify, ASSAO could be backported to 3.x, but only the GLES3 renderer. GTAO won't be effective until we have some form of temporal super sampling. GTAO won't be a good option for 3.x.

Calinou commented 2 years ago

Reopening, as this is still something we should aim to address in 3.x in some way.