godotengine / godot

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

FSR2 and TAA are affecting MultiMeshes in weird ways #93958

Closed Zylann closed 6 days ago

Zylann commented 3 months ago

Tested versions

Godot 4.2 Godot 4.3 beta2

System information

Windows 10 64 bits NVIDIA GeForce GTX 1060

Issue description

I got a report from someone who got a strange issue going on when multimesh buffers get modified, causing instances to get corrupted: https://github.com/Zylann/godot_voxel/issues/670

Investigating revealed that FSR2 seems to cause the issue. Turning it off makes the issue non-reproducible.

I tried making a simple project where I generate multimeshes and randomly edit and change their visible counts. Despite not being able to reproduce a situation that looks the same, I could still observe a striking difference in behavior between enabling FSR2 and not enabling it. This is not expected.

Steps to reproduce

Minimal reproduction project (MRP)

MultiMeshFSR2.zip (Godot 4.3 beta2)

This project defaults to a scaled down 3D rendering, using bilinear scaling.

image

image ^ Result after 5 presses.

image ^ Result after 5 presses

Maybe the repro can be simplified further. I mostly tried to reproduce a scenario close to what happens in the full project.

Calinou commented 3 months ago

Does this behavior change if you change the Threaded Cull threshold to a much higher value in the project settings (so that threaded culling is not used)?

Zylann commented 3 months ago

The scene has only 16 multimesh instances, which is way below the default threshold (1000). I tried anyways to raise it to the maximum I could (65536) and that had no effect. Also, as shown in the video of the linked issue, the problem doesn't just make multimesh instances disappear, it corrupts their transforms so sometimes they show up with random scales or flicker around the camera.

TAA also appears to have the same issue.

DarioSamo commented 3 months ago

While I can't investigate this in detail at the moment, the points of interest is any functionality that affects multimesh and the doubling in size of its transforms buffer when TAA/FSR2 is enabled, which is required for motion vectors.

void MeshStorage::_multimesh_enable_motion_vectors(MultiMesh *multimesh)
void MeshStorage::_multimesh_get_motion_vectors_offsets(RID p_multimesh, uint32_t &r_current_offset, uint32_t &r_prev_offset)
Rudolph-B commented 6 days ago

I failed to replicate this in the current master branch. After investigating it appears that this was fixed with #95270.

clayjohn commented 6 days ago

Thanks for confirming!

Closing as fixed.