godotengine / godot

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

Vulkan: SDFGI leaks light into enclosed spaces, even when Use Occlusion is enabled #50770

Open WickedInsignia opened 3 years ago

WickedInsignia commented 3 years ago

Godot version

Godot 4 nightly build

System information

Windows 10 v20H2, Intel i7 6700, Nvidia GTX1080, 16GB RAM

Issue description

Depending on distance from the subject mesh, SDFGI will unrealistically leak light into an enclosed or partially-enclosed space. This seems to be due to cascade switching due to the camera's proximity and will change as the camera approaches. These shifts otherwise appear as upscaling of GI detail but are highly noticeable in spaces where light should not be leaking. These spaces will begin bright and progressively darken.

This could simply be a limitation of SDFGI, but I thought it worth bringing to attention. This could not be resolved with quality tweaking (setting the cascades to the maximum of 8 and Y-scale to 50%) and adjusting the bias simply resulted in more extreme distortions.

Steps to reproduce

SDFGI will show traces of light leaking in any project with an enclosed space. In my experience thickness does not seem to affect this since when SDFGI is having a minimal effect due to camera proximity, Godot will default to displaying the space without GI information. In many cases, an enclosed space will be brighter under these conditions than SDFGI would usually introduce after enough resolution has been achieved to accurately portray the lighting.

Since the steps to reproduce are not exact and slightly arbitrary, I have provided screenshots and a reproduction below. At a distance, the light leak is quite obvious: SDFGI Light Leak 01

As the camera moves closer, the leak changes in nature and reduces but is still visible: SDFGI Light Leak 02

Finally, when maximum resolution is achieved the resulting GI will be considerably different than at a distance: SDFGI Light Leak 03

Minimal reproduction project

I have provided an example file with a couple basic meshes and a capsule to represent the size of a regular player: SDFGI_Leaking_Bug.zip

Here are some screenshots of the effects that may be observed: The leftmost structure mimics the above example. From a distance, it appears that light is spilling in from the roof: SDFGI Light Leak 04

Upon closer inspection, the lighting adjusts and the space appears enclosed with some minor leaking in the left corner: SDFGI Light Leak 05

The rightmost structure is entirely enclosed. Although this improves the situation, there is still some noticeable leaking in the right corners. Some strange lighting artifacts will also appear on the walls as the camera travels through the space (not displayed here): SDFGI Light Leak 06

All shots taken with 8 cascades and a Y scale of 50%.

Calinou commented 3 years ago

Check Use Occlusion in the environment SDFGI properties to reduce the amount of light leaking, and use thicker walls to make leaks even less noticeable. In general, global illumination techniques other than lightmaps will always require making walls thick. If you absolutely need thin walls and global illumination, it's better to use lightmaps instead.

SDFGI occlusion has a performance cost, which is why it's disabled by default. Not all scenes will suffer from significant amounts of light leaking, so it's better to keep it disabled by default to avoid incurring a performance cost on people who don't need it.

WickedInsignia commented 3 years ago

Occlusion is ticked on in these examples and the walls of the meshes are appropriately thick for what could be expected in a game space that blends interior and exterior spaces. In the case of the rightmost structure, the walls are considerably thicker than what could be expected in structures in-game.

Calinou commented 3 years ago

To reduce light leaking when using GIProbe, you can add additional geometry before baking GI then hide the geometry after baking, but it's not possible to do this with SDFGI due to how it works.

SDFGI is planned to get a rework after Godot 4.0 is released, but I don't see any way to address this until then.

WickedInsignia commented 3 years ago

That's all good and definitely what I expected. Since these effects aren't well-catalogued, I thought it best to take the time to make some examples. My hope is that if the issue is known and well-reproduced it will make future actions to address it a bit easier to identify.