bevy/crates
Patrick Walton 0517b9621b
Fix motion vector computation after #17688. (#17717)
PR #17688 broke motion vector computation, and therefore motion blur,
because it enabled retention of `MeshInputUniform`s, and
`MeshInputUniform`s contain the indices of the previous frame's
transform and the previous frame's skinned mesh joint matrices. On frame
N, if a `MeshInputUniform` is retained on GPU from the previous frame,
the `previous_input_index` and `previous_skin_index` would refer to the
indices for frame N - 2, not the index for frame N - 1.

This patch fixes the problems. It solves these issues in two different
ways, one for transforms and one for skins:

1. To fix transforms, this patch supplies the *frame index* to the
shader as part of the view uniforms, and specifies which frame index
each mesh's previous transform refers to. So, in the situation described
above, the frame index would be N, the previous frame index would be N -
1, and the `previous_input_frame_number` would be N - 2. The shader can
now detect this situation and infer that the mesh has been retained, and
can therefore conclude that the mesh's transform hasn't changed.

2. To fix skins, this patch replaces the explicit `previous_skin_index`
with an invariant that the index of the joints for the current frame and
the index of the joints for the previous frame are the same. This means
that the `MeshInputUniform` never has to be updated even if the skin is
animated. The downside is that we have to copy joint matrices from the
previous frame's buffer to the current frame's buffer in
`extract_skins`.

The rationale behind (2) is that we currently have no mechanism to
detect when joints that affect a skin have been updated, short of
comparing all the transforms and setting a flag for
`extract_meshes_for_gpu_building` to consume, which would regress
performance as we want `extract_skins` and
`extract_meshes_for_gpu_building` to be able to run in parallel.

To test this change, use `cargo run --example motion_blur`.
2025-02-18 09:34:19 +00:00
..
bevy_a11y Cleanup publish process (#17728) 2025-02-09 17:46:19 +00:00
bevy_animation Cleanup publish process (#17728) 2025-02-09 17:46:19 +00:00
bevy_app feat(ecs): configurable error handling for fallible systems (#17753) 2025-02-11 18:36:08 +00:00
bevy_asset Fill out some missing docs for bevy_assets (#17829) 2025-02-13 21:08:09 +00:00
bevy_audio Support decibels in bevy_audio::Volume (#17605) 2025-02-10 21:26:43 +00:00
bevy_color Upgrade to wgpu v24 (#17542) 2025-02-09 19:40:53 +00:00
bevy_core_pipeline Remove prepasses from the render world when they're removed from the main world. (#17565) 2025-02-14 06:43:35 +00:00
bevy_derive Cleanup publish process (#17728) 2025-02-09 17:46:19 +00:00
bevy_dev_tools Cleanup publish process (#17728) 2025-02-09 17:46:19 +00:00
bevy_diagnostic Cleanup publish process (#17728) 2025-02-09 17:46:19 +00:00
bevy_dylib Cleanup publish process (#17728) 2025-02-09 17:46:19 +00:00
bevy_ecs Improve the docs for ChildOf and Children (#17886) 2025-02-17 01:46:11 +00:00
bevy_encase_derive Harden proc macro path resolution and add integration tests. (#17330) 2025-02-09 19:45:45 +00:00
bevy_gilrs Cleanup publish process (#17728) 2025-02-09 17:46:19 +00:00
bevy_gizmos Harden proc macro path resolution and add integration tests. (#17330) 2025-02-09 19:45:45 +00:00
bevy_gltf Fixed bevy_image and bevy_gltf failing to compile with some features. (#17887) 2025-02-17 05:10:13 +00:00
bevy_image Fixed bevy_image and bevy_gltf failing to compile with some features. (#17887) 2025-02-17 05:10:13 +00:00
bevy_input Cleanup publish process (#17728) 2025-02-09 17:46:19 +00:00
bevy_input_focus Cleanup publish process (#17728) 2025-02-09 17:46:19 +00:00
bevy_internal Fix dds feature enabling bevy_gltf (#17888) 2025-02-17 03:33:17 +00:00
bevy_log Bump Rust tracy client version (#17867) 2025-02-15 21:07:40 +00:00
bevy_macro_utils Fix failing proc macros when depending on bevy through dev and normal dependencies. (#17795) 2025-02-11 18:28:15 +00:00
bevy_math Add ways to configure EasingFunction::Steps via new StepConfig (#17752) 2025-02-11 22:19:01 +00:00
bevy_mesh Retain skins from frame to frame. (#17818) 2025-02-18 00:56:04 +00:00
bevy_mikktspace Update typos to 1.29.6 (#17850) 2025-02-13 19:44:47 +00:00
bevy_pbr Fix motion vector computation after #17688. (#17717) 2025-02-18 09:34:19 +00:00
bevy_picking Update picking docs to include position space (#17859) 2025-02-15 19:08:12 +00:00
bevy_platform_support Cleanup publish process (#17728) 2025-02-09 17:46:19 +00:00
bevy_ptr Cleanup publish process (#17728) 2025-02-09 17:46:19 +00:00
bevy_reflect Add TypeRegistry::register_by_val (#17817) 2025-02-15 19:07:01 +00:00
bevy_remote Cleanup publish process (#17728) 2025-02-09 17:46:19 +00:00
bevy_render Fix motion vector computation after #17688. (#17717) 2025-02-18 09:34:19 +00:00
bevy_scene Allow users to register their own disabling components / default query filters (#17768) 2025-02-11 18:25:32 +00:00
bevy_sprite Make the specialized pipeline cache two-level. (#17915) 2025-02-18 07:23:33 +00:00
bevy_state Harden proc macro path resolution and add integration tests. (#17330) 2025-02-09 19:45:45 +00:00
bevy_tasks Cleanup publish process (#17728) 2025-02-09 17:46:19 +00:00
bevy_text Allowed creating uninitialized images (for use as storage textures) (#17760) 2025-02-10 22:22:07 +00:00
bevy_time Cleanup publish process (#17728) 2025-02-09 17:46:19 +00:00
bevy_transform Add EntityDoesNotExistError, replace cases of Entity as an error, do some easy Resultification (#17855) 2025-02-16 21:59:46 +00:00
bevy_ui Update picking docs to include position space (#17859) 2025-02-15 19:08:12 +00:00
bevy_utils Cleanup publish process (#17728) 2025-02-09 17:46:19 +00:00
bevy_window Cleanup publish process (#17728) 2025-02-09 17:46:19 +00:00
bevy_winit Allowed creating uninitialized images (for use as storage textures) (#17760) 2025-02-10 22:22:07 +00:00