godotengine / godot

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

Glow flashes a lot on reflections with FSR 2.2 enabled. #83317

Open viksl opened 1 year ago

viksl commented 1 year ago

Godot version

4.2 beta 1

System information

Windows 11 - Vulkan - Nvidia RTX 4070 - intel i5 13600KF

Issue description

When FSR2.2 is enabled the glow on reflections has some extreme flashing behaviour, it's not related to just this model, you can check more in the lumberyard demo (https://github.com/godotengine/godot/issues/74965), the model in this MRP is taken directly from that demo to a separate scene to isolate it for this report.

I've also set the values to higher ones to make sure no one can miss it. I did try teh luminance cap, unless it's at 0 (meaning the glow is disabled) it changes nothing - though increasing it increases the flashing more.

Check the video here: https://youtu.be/cPei3-hV40k

Steps to reproduce

Open the MRP, you should see a black screen with white flashes in the viewport, feel free to change the blend mode for the Glow in the world environment to see it differently, I set it up this way since it's the most obvious example.

Minimal reproduction project

GlowTest.zip

bitsawer commented 1 year ago

The glow got some improvements a few weeks ago, which might have also made it a bit more sensitive to flickering: https://github.com/godotengine/godot/pull/82353

This is possibly more of a Glow implementation issue rather than FSR, but ping at @DarioSamo in case he has some useful insight into this issue or possible workarounds/fixes.

Another test video from Lumberyard Bistro:

https://github.com/godotengine/godot/assets/22456603/b1a230ae-b5bd-40b7-a5bf-7ac01d9b4e13

edit:

Comment from Jamsers on RocketChat about the video above:

About this: while yes, the recent PR regarding glow made this worse, the core cause of this issue is actually wrong usage of the transparent material in the glass casing of the lantern: I think it's double sided so it's catching specular from the light inside - it should be one sided so it only catches specular from the outside. I'm planning to do a meshes and materials pass on the project at some point to fix these issues

Jamsers commented 12 months ago

Update on this: I've done my materials pass on Bistro-Demo-Tweaked and it turns out the materials were correct all along. I dug in further and can confirm that the core cause of the issue is FSR 2 itself. The recent glow PR exacerbates the issue, but is not the core cause. (The issue disappears completely if you turn off FSR 2 and use Godot TAA, for example)

What seems to be happening is that FSR 2 jitters and blurs transparencies but makes no attempt to actually upscale them. Here is a video showcasing that - the resolution in this video is set to 360p (1080p output). You'll notice the rest of the scene resolves to 1080p, but the transparencies (the lantern glass panel, the window panes, the "Le Petit Coin" decal) stay low res and jitter extremely.

https://github.com/godotengine/godot/assets/39361911/b0de5db8-80c2-4aeb-80fd-ab82cb54cf9c

It's not as noticeable the closer you get to native, but is still happening in the background, which causes the glow flashing regardless of resolution.

I distinctly remember that other games which implemented FSR 2 (like Deathloop) also had this issue with transparencies... @DarioSamo do we already output to the reactive mask with the current FSR 2 implementation in Godot? Would it even help?

I feel like the glow shader itself needs to take into account FSR/TAA jitter and do some temporal something something resolve in the first place... I think that's how it's handled in Unreal, for example.

DarioSamo commented 12 months ago

I distinctly remember that other games which implemented FSR 2 (like Deathloop) also had this issue with transparencies... @DarioSamo do we already output to the reactive mask with the current FSR 2 implementation in Godot? Would it even help?

We do output the reactive mask, but as indicated by performance concerns @reduz pointed out, we don't use a separate buffer for it but rather the alpha component that results from doing alpha blending. Therefore, anything alpha blended in the scene outputs the alpha value that was used for compositing as the value for the reactive mask.

Arguably this doesn't give as much control as we might need to address alpha blended objects that are mostly static, but I didn't get the greenlight on splitting the rendering to have this additional reactive mask that we could have bigger control of. It's an interesting point for sure.

Jamsers commented 12 months ago

we don't use a separate buffer for it but rather the alpha component that results from doing alpha blending

Oh that's pretty much the default approach recommended by AMD anyway, so honestly I don't think more specific/user controlled reactive mask will even help much then. Hmm... this may need to be solved in the glow shader itself. 🤷