godotengine / godot

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

Volumetric Fog with Temporal Reprojection + SpotLight3D attached to Player Camera is broken #93162

Open ghostbutter-games opened 2 months ago

ghostbutter-games commented 2 months ago

Tested versions

System information

Windows 10 - Godot v4.3 Beta 1 - Vulkan (Forward +) - Dedicated GPU (RTX 2080 Super)

Issue description

When experimenting with Godot and 3D features, I wanted to have a scene with SDFGI enabled, Volumetric Fog with Temporal Reprojection enabled and also a SpotLight3D that the player can use to affect the fog (attached to the Camera)

As one can see in the video below, whenever the player moves, there is very heavy ghosting/delay. This is even documented and known when hovering over the "Temporal Reprojection" setting.

The "solution" to this ghosting is to turn off Temporal Reprojection, but then the Volumetric Fog looks really bad and has heavy graphical glitches, especially together with SDFGI. So turning off the reprojection is not an option.

Turning on the reprojection is also not an option due to the ghosting.

How can I achieve the desired result in Godot 4, with Vol. Fog + Temp. Reprojection, SDFGI and Dynamic Lights that affect the fog?

Steps to reproduce

Minimal reproduction project (MRP)

See the issue in this screen cap:

https://github.com/godotengine/godot/assets/1736929/2f63d5e4-1149-4eac-9f21-c59645a865cf

Calinou commented 2 months ago

There is no ideal solution to this. You can either increase the rendered FPS (so volumetric fog converges faster) or reduce the temporal reprojection factor, but temporal reprojection factors that are too low will cause flickering. Try a value between 0.7 and 0.8.

Increasing the FPS beyond the monitor refresh rate also requires disabling V-Sync in the project settings, and making sure the graphics driver isn't forcing V-Sync.

You could also try to extrapolate the SpotLight's position based on the player's current movement velocity to counteract the ghosting, but this is bound to create some extrapolation errors when the player's velocity changes suddenly.