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 Artifacts due to sky sampling when Read Sky Light is enabled #61504

Open MidnightEdge opened 2 years ago

MidnightEdge commented 2 years ago

Godot version

4.0.alpha8

System information

Windows 10, Vulkan Clustered, RTX 3060Ti, 511.79

Issue description

Cross shaped and world normal aligned artifacts appear on objects when enabling SDFGI. It seems like SDFGI is sampling indirect lighting from incorrect directions. The scene in the screenshots only have a directional light, a WorldEnvironment node with a sky background and SDFGI enabled, and a sphere with a default white material. The sphere's global illumination mode is "disabled".

SDFGI On SDFGI On SDFGI Off SDFGI Off

Steps to reproduce

Add any object to a scene and enable SDFGI in the WorldEnvironment. Preferrably a white and smooth object, so that the artifacts are easier to spot.

Minimal reproduction project

SDFGI.zip

Calinou commented 2 years ago

Not related to this issue (for now), but you forgot to set the global illumination mode on the MeshInstance3D:

image

Set it to Static, then save and reload the scene. This won't make a visual difference if there is only one object in the scene, but it will once you add more objects to the scene for light to reflect on.

That said, the appearance looks expected to me. Read Sky Light likely has some inaccuracies in its sampling, but it's probably not noticeable in most real world scenes:

image

image

SDFGI Debug Cascades debug draw mode looks like this:

image

SDFGI Debug Cascades debug draw mode with much lower Cell Size and more compact Y scaling:

image

There does appear to be some singularities or something at some angles (which manifest as pitch-black spots):

image

I'm not sure if much can be improved here without decreasing performance. Increasing Normal Bias and/or Probe Bias can help, but it'll also make light leaking more noticeable.

MidnightEdge commented 2 years ago

I have left the GI Mode disable intentionally, to show that it seems to be an unrelated issue.

image

Here's a different scene, with Read Skylight and Occlusion disabled as well, even the probes seem to contain incorrect data. There's nothing to the right that could reflect light from the bottom, yet the probe has indirect lighting from that direction. image