godotengine / godot

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

Vulkan: Flashing Lights through Fog while Alt+Tabbed #61222

Open cnjeffer opened 2 years ago

cnjeffer commented 2 years ago

Godot version

Godot_v3.4.4-stable_win64

System information

Windows 10, Intel Core i9-9900k, Nvidia RTX 2070 Super

Issue description

Fast flashing light occurs when I alt-tab from my Godot project, only happens in certain areas.

2022-05-20 22_31_05-Window 2022-05-20 22_31_29-Window

Steps to reproduce

!!! WARNING FLASHING LIGHTS !!!

https://user-images.githubusercontent.com/68210683/169533668-8923a85d-cfd3-47e9-92eb-707155439da7.mp4

Minimal reproduction project

couldn't upload zip, maybe 30mbs is too much? here's a GDrive link https://drive.google.com/file/d/1dzYtAY3YB0DYOTQvvImt5EmC49KyXj06/view?usp=sharing

Calinou commented 2 years ago

couldn't upload zip, maybe 30mbs is too much?

Indeed, GitHub attachments are limited to 10 MB.

sDeemm commented 2 years ago

I tested it in master since I have a similar system and the issue is reproducible.

The feature that causes trouble is the Auto Exposure. The MRP uses the following parameters

image

Note that, the scale is at the minimum while the speed is at its maximum.

While Alt+Tabbed godot runs at 100ms.

Given

double step = env->auto_exp_speed * time_step;

Used in shader (params.exposure_adjust):

avg = clamp(prev_lum + (avg - prev_lum) * params.exposure_adjust, params.min_luminance, params.max_luminance);

Considering that exposure_adjust is 64 * 100ms = 6.4 and the scene's avg luminance is near the minimum. The avg result flickers between the min_luminance and the average luminence value.

Can you reproduce this after enabling Interface > Editor > Update Continuously in the Editor Settings?

It does fixes the problem since the frame rate of godot will not "drop" when alt+tabbed.

I'm wondering what would be the next step for this issue...

clayjohn commented 2 years ago

I tested it in master since I have a similar system and the issue is reproducible.

The feature that causes trouble is the Auto Exposure. The MRP uses the following parameters

image

Note that, the scale is at the minimum while the speed is at its maximum.

While Alt+Tabbed godot runs at 100ms.

Given

double step = env->auto_exp_speed * time_step;

Used in shader (params.exposure_adjust):

avg = clamp(prev_lum + (avg - prev_lum) * params.exposure_adjust, params.min_luminance, params.max_luminance);

Considering that exposure_adjust is 64 * 100ms = 6.4 and the scene's avg luminance is near the minimum. The avg result flickers between the min_luminance and the average luminence value.

Can you reproduce this after enabling Interface > Editor > Update Continuously in the Editor Settings?

It does fixes the problem since the frame rate of godot will not "drop" when alt+tabbed.

I'm wondering what would be the next step for this issue...

Great work! The next step is to research how other auto exposure implementations work and determine if this line of code needs to change or another line of code. IMO auto exposure should be robust enough that it can handle variable frame rates. At the same time, perhaps the chosen speed is way outside a reasonable range, so perhaps its the range exposed in the editor that needs to change. Either way, a little bit of research is needed to form a good opinion on what to do next

Calinou commented 11 months ago

I wonder if https://github.com/godotengine/godot/pull/82222 can help with this.