godotengine / godot

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

Vulkan: viewport flashes white when being resized with volumetric fog enabled #63739

Open atirut-w opened 2 years ago

atirut-w commented 2 years ago

Godot version

v4.0.alpha13.official [59dcddc45]

System information

Fedora Linux 36 (Workstation Edition), Vulkan Clustered, GTX 1660

Issue description

When the viewport is being resized with VL fogs enabled, it flashes white for about a single frame.

(Epilepsy warning)

https://user-images.githubusercontent.com/25323231/182040843-e52dc349-d503-49a5-aeb7-d13e78fdc5e9.mp4

Steps to reproduce

  1. Enable volumetric fog
  2. Resize viewport

Minimal reproduction project

No response

Calinou commented 2 years ago

Related to https://github.com/godotengine/godot/issues/62794.

Do you also have SSIL enabled in the Environment?

atirut-w commented 2 years ago

Disabling SSIL doesn't seem to have an effect on the flashing

clayjohn commented 2 years ago

I took a quick look into this, the problem is that, when the viewport is resized, the Fog buffers are deleted and then recreated, but in the meantime the sky/objects are drawn. Since the fog buffers are not initialized yet a plain white texture is used instead leading to the flicker.

The solution will be to update the volumetric fog textures immediately after deletion/creation so there is no blip

Calinou commented 2 years ago

I can still reproduce this on 4.0.beta3.

Quoting clayjohn from the Godot Contributors Chat:

It is a known issue and we have a few options to resolve it. Its not caused by temporal reprojection, it happens because the volumetric fog buffer gets deleted right before rendering the frame again so the next frame after the clear uses the default clear values.

I think the best option is, instead of clearing the newly allocated fog buffer, we should copy the old fog buffer over and just stretch/squash it to fit, it won't be perfect if size/aspect change a lot, but it should help

The same approach can also be used to fix https://github.com/godotengine/godot/issues/56724.

viksl commented 9 months ago

Still reproducible in 4.3, I just wanted to add that bottom panels chagne the viewport too and with the FileSystem being dockable (and in the future releases possibly other panels soo) and the shortcuts to open/close these panels this is getting quite prominent since the new workflow encourages fluidly opening and closing the panels, I've noticed this testing the PRs and the flashing gets really apparent and annoying ;0.

Mantle-Core commented 4 months ago

I can still reproduce this on 4.0.beta3.

Quoting clayjohn from the Godot Contributors Chat:

It is a known issue and we have a few options to resolve it. Its not caused by temporal reprojection, it happens because the volumetric fog buffer gets deleted right before rendering the frame again so the next frame after the clear uses the default clear values. I think the best option is, instead of clearing the newly allocated fog buffer, we should copy the old fog buffer over and just stretch/squash it to fit, it won't be perfect if size/aspect change a lot, but it should help

The same approach can also be used to fix #56724.

@clayjohn I came down to using a double buffer. Here is my results:

Before

https://github.com/godotengine/godot/assets/169231366/6461077d-6bed-41b1-aa06-6d72ab421656

After

https://github.com/godotengine/godot/assets/169231366/349c76c3-20ad-400d-ae78-5bdb3d3eead0

I did some testing by just saving the current state and reusing it without these buffers, but that just completely turned off the volume.

As you can see:

Calinou commented 4 months ago

This looks great, but doesn't using a double buffer mean there's an additional frame of latency? This might not be a huge deal in most cases given volumetric fog is low-frequency data, but still.

Mantle-Core commented 4 months ago

I tried a variety of things, but I ended up using the earlier suggestion to fix it. I just reused the previous fog buffer. It looks the same as the "After" video.