godotengine / godot

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

Vulkan: TAA does not make the editor redraw until it has fully converged #62887

Open Calinou opened 2 years ago

Calinou commented 2 years ago

Related to https://github.com/godotengine/godot/issues/54892, https://github.com/godotengine/godot/issues/54893 and https://github.com/godotengine/godot/issues/56723.

Godot version

4.0.alpha11, 4.3.dev4

System information

Fedora 36, GeForce GTX 1080 (NVIDIA 510.68.02)

Issue description

Temporal antialiasing (TAA) does not make the editor redraw until it has fully converged. This means that when toggling TAA or changing a setting that causes it to regenerate (such as resizing the editor viewport), it will have partially-converged appearance until you move the 3D camera around a bit (or cause the editor viewport to update somehow, e.g. by hovering controls).

We should resolve this by forcing the engine to redraw for 16 frames every time something is updated when both TAA and low processor mode are enabled.[^1] (16 frames is the duration of the Halton jitter sequence used by TAA.)

[^1]: We shouldn't just do this when the camera moves, as other objects being updated (such as a mesh's visibility being toggled) also requires the TAA to fully converge to look good – even if the camera doesn't move.

Steps to reproduce

Minimal reproduction project

N/A

DarioSamo commented 1 year ago

Part of my proposal for FSR 2 requires to add a flag for discarding the history of the scene to the viewport ("reset accumulation"). This is just a boolean that should be used and cleared once the accumulation is reset. Adding this kind of control seems like it'd allow fixing this issue easily.

Adding this setting to the viewport would be beneficial for this case as well as the editor could clear the flag correctly whenever a setting changes. The current TAA implementation can also be extended to take this setting into account to properly clear the history buffer. This would give users all the control they need over resetting the effect of temporal accumulation techniques when major changes occur in the scene.

Maybe we could split this idea into a proposal instead?

Calinou commented 11 months ago

Adding this kind of control seems like it'd allow fixing this issue easily.

While we need a "reset accumulation" method, we still need to force drawing until the rendering has fully converged when using low-processor mode. Otherwise, you'll be left with an aliased image unless something in the scene happens to be forcing redrawing (such as a shader using TIME or an active animation).

Now that FSR2 is implemented, this also means we should add a method to return the number of frames required to fully converge TAA (since this varies depending on FSR2 input resolution scale). Having this exposed separately is useful for scripts that automatically take screenshots, so that you can wait until the image is fully converged before taking the screenshot.