godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.16k stars 97 forks source link

Add depth aware upscaling for post-processing effects #10497

Closed Rytelier closed 2 months ago

Rytelier commented 2 months ago

Describe the project you are working on

3D game

Describe the problem or limitation you are having in your project

Post-processing effects such as global illumination, ambient occlusion produce very nasty looking pixelization around edges when running at half resolution. image Issue can be solved by setting them to use full resolution, but it affects performance.

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

Add depth aware upscaling - method of upscaling screen buffers from lower resolution to full using depth buffer as guidance on how the pixel should cover the areas, resulting in smoothed edges.

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

When an effect is set to render at lower resolution, an additional filter pass is applied to the effect buffers that upscales them before being used in the render.

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

It can't be added in a script.

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

Improves quality of built-in effects.

Calinou commented 2 months ago

I thought bilateral upscale was already used for SSAO. Maybe that was only in the 3.x implementation of SAO (4.x uses ASSAO).

Note that using TAA or FSR2 does a good job of hiding artifacts on half-resolution GI buffers in my experience. With upscaling from a lower resolution, you might not need half-resolution GI either. When upscaling from a lower-than-native resolution, you might not need half-resolution GI either.

clayjohn commented 2 months ago

Here is the current upscaling code for GI: https://github.com/godotengine/godot/blob/da5f39889f155658cef7f7ec3cc1abb94e17d815/servers/rendering/renderer_rd/shaders/forward_clustered/scene_forward_clustered.glsl#L1578-L1602

it looks like we only take normals into account

SSAO is here: https://github.com/godotengine/godot/blob/da5f39889f155658cef7f7ec3cc1abb94e17d815/servers/rendering/renderer_rd/shaders/effects/ssao_interleave.glsl#L54

Rytelier commented 2 months ago

It looks like SSAO has upsampling, but still has some flaws image image VoxelGI/SDFGI looks like the upscaling just doesn't work at all. Probably it needs a bug report in that case?

Note that using TAA or FSR2 does a good job of hiding artifacts on half-resolution GI buffers in my experience.

The visuals should look good without the need of TAA.

clayjohn commented 2 months ago

VoxelGI/SDFGI looks like the upscaling just doesn't work at all. Probably it needs a bug report in that case?

I think so, yes

Calinou commented 2 months ago

Closing in favor of https://github.com/godotengine/godot/issues/95865, as this is considered a bug.