godotengine / godot

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

`Directional` property on `LightmapGI` node causes invalid pixels. #95875

Closed EMBYRDEV closed 2 weeks ago

EMBYRDEV commented 3 weeks ago

Tested versions

4.3.stable

System information

Godot v4.3.stable - Windows 10.0.22631 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 2070 SUPER (NVIDIA; 32.0.15.6070) - AMD Ryzen 9 7950X 16-Core Processor (32 Threads)

Issue description

Switching on directional lightmapping can lead to invalid pixels that when paired with autoexposure can completely corrupt the scene.

LightmapGI non-directional: image

LightmapGI directional: image

Directional with moved camera: image

Steps to reproduce

  1. Download project: https://github.com/perfoon/Abandoned-Spaceship-Godot-Demo
  2. Enable autoexposure in the Hangar's world environment
  3. Bake lightmap using OIDN (havent tested with JNLM)
  4. Observe lack of artifacting
  5. Bake lightmap with Directional enabled.
  6. Observe massive bloom and severe artifacting when rotating camera.

Minimal reproduction project (MRP)

https://github.com/perfoon/Abandoned-Spaceship-Godot-Demo

clayjohn commented 3 weeks ago

I wonder if this is the same as https://github.com/godotengine/godot/issues/81556. We could be getting NaNs that get propagated by the auto exposure

EMBYRDEV commented 3 weeks ago

I wonder if this is the same as #81556. We could be getting NaNs that get propagated by the auto exposure

Potentially, I'm getting some similar looking specular in some parts of the scene image

Calinou commented 3 weeks ago

The NaN propagation issue related to the lightmap no longer occurs with https://github.com/godotengine/godot/pull/95888, but that PR still seems to struggle with baked light on alpha-tested materials. Baking with Directional enabled still creates a brighter overall lightmap with flickering occuring when Glow is enabled:

Directional OFF Directional ON
image image

Probes also have negative-looking artifacts, but these are present regardless of whether Directional is enabled:

Directional OFF Directional ON
image image

Dynamic objects themselves look fine though, so maybe this is just an issue with the visualization.

Edit: The scene gets extremely bright (but not NaN) as I save the scene, or switch back to the main scene after baking in the Hangar scene:

image

The issue is connected to the first ReflectionProbe node in Hangar. Hiding it fixes the issue, even after switching back to the main scene.

The issue occurs even if the ReflectionProbe's ambient mode is set to Disabled and its Intensity is reduced to 0.01. However, it does not occur anymore if you switch its update mode to Always, which uses a real-time filtering method for (ir)radiance. This means the culprit is likely the high-quality filter mode for reflection probes, which is used for the Once update mode.

BlueCube3310 commented 2 weeks ago

but that PR still seems to struggle with baked light on alpha-tested materials. Baking with Directional enabled still creates a brighter overall lightmap with flickering occuring when Glow is enabled:

These look like ringing artifacts that occur due to sampling the SH lightmap's lower hemisphere, which has negative colors.

Edit: A way to mitigate this has been described in https://web.archive.org/web/20160313132301/http://www.geomerics.com/wp-content/uploads/2015/08/CEDEC_Geomerics_ReconstructingDiffuseLighting1.pdf