Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vulkan Volumetric Fog Issue #93833

Closed

Conversation

Mantle-Core
Copy link

@Mantle-Core Mantle-Core commented Jul 1, 2024

Issue
Fixes #62794

Godot version
4.x

System information

  • OS: Windows
  • Architecture: x86_64
  • GPU: Nvidia 1050ti

Description
This fix calculates the number of frames needed, based on the temporal reprojection amount, to redraw until the volumetric fog fully converges.

Note: Another issue related to the flickering when adjusting the viewport has already been addressed.

Changes Made

  • New Variables in renderer_viewport.h:
    • int frames_needed;: Stores the number of frames needed for the volumetric fog to converge.
    • Size2i old_size;: Stores the previous size of the viewport. Used to check if the viewport was resized.

Additional Information

Volume.Fog.mp4

@@ -286,11 +288,17 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) {
// The scene renderer will still copy over the last frame, so we need to clear the render target.
force_clear_render_target = true;
}

// Calculate the frames needed for volumetric fog to converge.
if (p_viewport->size != p_viewport->old_size && can_draw_3d) {
Copy link
Member

@Calinou Calinou Jul 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resizing the viewport is not the only thing that can require reconverging volumetric fog.

A lot of other things can require redrawing for the volumetric fog preview to remain accurate. In order of importance (from most to least important):

  • Toggling volumetric fog or changing one of its properties.
  • Hiding or showing a FogVolume node, or changing one of its material properties.
  • Hiding or showing a light that effects volumetric fog, or changing one of its properties.
  • Hiding or showing a mesh that blocked a light (through shadows), and where the shadow was visible in the volumetric fog.

This is a lot to keep track of, so it might be better to always redraw for the volumetric fog duration whenever volumetric fog is enabled. We should try to do this only if something 3D-related happened though, so that UI-only updates do not force a full redraw of both 2D and 3D (they are always drawn at the same time).

Also, we'll need several other things that keep track of a "frames needed" variables in the future, such as:

  • Temporal antialiasing/FSR2 (8 frames for TAA, variable for FSR2 according to the viewport's 3D resolution scale).
  • SSIL (1 frame delay after a viewport resize).
  • SDFGI (30 frames delay, adjustable in project settings).

You don't need to implement these in this PR; it's just a note for later to make sure we don't need to copy-paste too much code around.

@AThousandShips AThousandShips added this to the 4.3 milestone Jul 2, 2024
@AThousandShips
Copy link
Member

You used a merge commit to update your branch, please use rebase in the future instead, see here

Issue: godotengine#62794

This fix calculates the number of frames needed, based on the temporal reprojection amount, to redraw until the volumetric fog fully converges.
@Mantle-Core Mantle-Core closed this Jul 5, 2024
@Mantle-Core Mantle-Core deleted the vulkan-volumetric-fog-issue branch July 5, 2024 08:03
@AThousandShips AThousandShips removed this from the 4.3 milestone Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants