godotengine / godot

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

Derived Motion Vectors broken between 4.3 dev 5 and dev6 #91758

Closed mrjustaguy closed 5 months ago

mrjustaguy commented 5 months ago

Tested versions

Happens 4.3 Dev 6 Doesn't in 4.3 Dev 5 and earlier

System information

Windows 11, i3-10105f, RX6600 24.4.1, Forward+

Issue description

Derived Motion Vectors are Broken resulting in broken FSR2 Behaviors When zooming out these are the results

image

Expected

image

Steps to reproduce

Enable FSR and move around, Looking at the Motion Vectors

Minimal reproduction project (MRP)

N/A

DarioSamo commented 5 months ago

The blue motion vectors are derived from the camera and the depth value. Is it possible it's related to reverse depth? I'd try before and after this commit https://github.com/godotengine/godot/commit/69a4ff899618cc40bcf5aed2130d4cb2e3c021d6.

clayjohn commented 5 months ago

~I can't reproduce this issue. I've tested a basic scene with a plane mesh with Dev 5, Dev 6 and current master.

Can you upload an MRP that reproduces the issue? There must be something about your mesh that is impacting this

Notably, my motion vectors are also always yellow rather than blue. So I'm clearly not even triggering the same codepath you are~

Edit: I figured it out. This is only reproducible when using FSR2. TAA is not affected

mrjustaguy commented 5 months ago

Yeah my bad, TAA is just it's regular old broken self due to it's own issues and hasn't regressed.. updated OP

DarioSamo commented 5 months ago

The blue motion vectors are derived from the camera and the depth value. Is it possible it's related to reverse depth? I'd try before and after this commit 69a4ff8.

I've tested the commit before and after reverse Z and I can confirm this issue was introduced during that, and it seems to affect the derivation of the motion vectors from depth in particular that is used for FSR2. I'm not entirely sure why it breaks and how to fix it yet, but that's the starting point for this.

mrjustaguy commented 5 months ago

https://github.com/godotengine/godot/blob/master/servers/rendering/renderer_rd/shaders/effects/motion_vector_inc.glsl maybe?

DarioSamo commented 5 months ago

https://github.com/godotengine/godot/blob/master/servers/rendering/renderer_rd/shaders/effects/motion_vector_inc.glsl maybe?

That is independent of the math. I opened this PR that seemingly fixes the issue and it makes enough sense to me at least: https://github.com/godotengine/godot/pull/91799