Skip to content
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

Motion vector animated mesh #13075

Closed
wants to merge 7 commits into from

Conversation

JMS55
Copy link
Contributor

@JMS55 JMS55 commented Apr 23, 2024

Objective

Solution

  • The new render world resource AnimatedMeshMotionVectors controls whether to enable motion vectors for these types of meshes. TAA enables it by default.
  • Lots of complicated logic to bind the previous uniforms for skins and morph targets, and the various combinations thereof
  • There are many possible variations:
    1. Motion vectors disabled
    2. Motion vectors enabled, animated mesh support disabled
    3. Motion vectors enabled, animated mesh support enabled, but no uniform buffers last frame (first frame of rendering)
    4. Motion vectors enabled, animated mesh support enabled, uniform buffer from last frame exists, but mesh did not exist/have animated components last frame, and does not have an entry in the previous frame uniform buffer
  • Push constants are used to handle case 4, where the push constant (0/1) masks out the motion vector.
    • Probably should think more about this, as it'll break TAA on WebGPU. A new bit in MeshFlags might be better, but the flags are built in extract_meshes_for_cpu/gpu_building, and we won't know whether to sit the bit or not until after extract_skins and extract_morphs...
  • Also removed the old push constant usage left around from the old instance_index.wgsl workaround, which got removed at some point

TODO

  • Modify SetBindGroup to set the dynamic offsets for previous frame morph and/or skin buffers when they are bound, and set the appropriate push constant.
  • Modify prepass.wgsl to calculate previous_world_position for skinned and/or morph target meshes.
  • Update prepass example to show animated meshes
  • Docs

Changelog

This section is optional. If this was a trivial fix, or has no externally-visible impact, you can delete this section.

  • What changed as a result of this PR?
  • If applicable, organize changes under "Added", "Changed", or "Fixed" sub-headings
  • Stick to one or two sentences. If more detail is needed for a particular change, consider adding it to the "Solution" section
    • If you can't summarize the work, your change may be unreasonably large / unrelated. Consider splitting your PR to make it easier to review and merge!

Migration Guide

This section is optional. If there are no breaking changes, you can delete this section.

  • If this PR is a breaking change (relative to the last release of Bevy), describe how a user might need to migrate their code to support these changes
  • Simply adding new functionality is not a breaking change.
  • Fixing behavior that was definitely a bug, rather than a questionable design choice is not a breaking change.

@JMS55 JMS55 added C-Feature A new feature, making something new possible A-Rendering Drawing game state to the screen labels Apr 23, 2024
@JMS55
Copy link
Contributor Author

JMS55 commented May 2, 2024

This is too much of a pain :/

@JMS55 JMS55 closed this May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Feature A new feature, making something new possible
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant