-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
Improve handling of motion vectors for multimesh instances. #80414
Improve handling of motion vectors for multimesh instances. #80414
Conversation
Fixes godotengine#67287. There was a subtle error where due to how enabling motion vectors for multi-meshes was handled, only the first instance would have a valid transforms buffer and the rest would point to an invalid buffer. This change moves over the responsibility of enabling motion vectors only when changes happen to the individual 3D transforms or the entire buffer itself. It also fixes an unnecessary download of the existing buffer that'd get overwritten by the current cache if it exists. Another fix is handling the case where the buffer was not set, and enabling motion vectors would not cause the buffer to be recreated correctly.
4e4fcb0
to
5155870
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks good to me. Tested locally and it works in the MRP from the linked issue
Thanks! |
It seems this PR introduces a regression where the regular Platformer project's terrain breaks when TAA is enabled. I'm unsure as to why this happens yet but it might be reasonable to revert it until the fix is implemented and re-opening this PR. |
#80552 should fix the regression. |
There's another regression that I'm unsure how to fix at the moment introduced where particles are broken when TAA is enabled due to removing the following condition.
As per Juan's recommendation, the condition for enabling multimesh motion vectors was moved to mesh storage itself. However, mesh storage is unable to know whether the multimesh is used by particles or not. It seems enabling multimesh motion vectors in general will break particles in the current implementation. So this PR also introduces that regression unless it can be figured out how to exclude particles from this or fix the issue which affects the particle transforms in particular. If we'd like to keep the fix as it is we'd need to introduce a way a new flag for multimesh to support enabling motion vectors or not upon creation. For the moment I'll keep researching into how particle rendering uses this and why it's affected, but if not we might need to revert this before considering this for 4.2. |
After discussing with @clayjohn I'll be looking at attempting to implement MVs for Particles during the week instead so we can fix the root cause of the problem. |
…engine#80414. There was an error in the other branch of the refactored function where the size of the array was not properly multiplied by the size of the float to check against the buffer size. This was only an error in the error-checking itself and not the functionality. There was also an error where the proper notification was not emitted whenever the buffer for the multimesh is recreated to invalidate the previous references the renderer might've created to it. This fixes CPU Particles getting corrupted when they're created without emission being enabled.
As it turns out, the issue was not for GPU particles but for CPU particles, so merely introducing the dependency notification to discard the uniform set when the multimesh buffer is recreated seems to have fixed the problem. I've appended the fix in #80552, so if nothing new shows up there should be no need to revert this. |
Fix critical regressions introduced in PR #80414
Cherry-picked for 4.1.2 (together with #80552). |
…engine#80414. There was an error in the other branch of the refactored function where the size of the array was not properly multiplied by the size of the float to check against the buffer size. This was only an error in the error-checking itself and not the functionality. There was also an error where the proper notification was not emitted whenever the buffer for the multimesh is recreated to invalidate the previous references the renderer might've created to it. This fixes CPU Particles getting corrupted when they're created without emission being enabled. (cherry picked from commit 420f389)
…engine#80414. There was an error in the other branch of the refactored function where the size of the array was not properly multiplied by the size of the float to check against the buffer size. This was only an error in the error-checking itself and not the functionality. There was also an error where the proper notification was not emitted whenever the buffer for the multimesh is recreated to invalidate the previous references the renderer might've created to it. This fixes CPU Particles getting corrupted when they're created without emission being enabled.
Fixes #67287. There was a subtle error where due to how enabling motion vectors for multi-meshes was handled, only the first instance would have a valid transforms buffer and the rest would point to an invalid buffer.
I've done some testing with the multi-mesh project on the referenced issue as well as making a script to animate the instances and check if motion vectors are being drawn.
More extensive testing is recommended on projects that make heavy use of multimesh and also use TAA.
Design quirks