-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Fix motion blur on skinned meshes #18712
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
Fix motion blur on skinned meshes #18712
Conversation
…s`. This fixes specialization caching the wrong flag.
## Objective Fix motion blur not working on skinned meshes. ## Solution `set_mesh_motion_vector_flags` can set `RenderMeshInstanceFlags::HAS_PREVIOUS_SKIN` after specialization has already cached the material. This can lead to `MeshPipelineKey::HAS_PREVIOUS_SKIN` never getting set, disabling motion blur. The fix is to make sure `set_mesh_motion_vector_flags` happens before specialization. Note that the bug is fixed in a different way by #18074, which includes other fixes but is a much larger change. ## Testing Open the `animated_mesh` example and add these components to the `Camera3d` entity: ```rust MotionBlur { shutter_angle: 5.0, samples: 2, #[cfg(all(feature = "webgl2", target_arch = "wasm32", not(feature = "webgpu")))] _webgl2_padding: Default::default(), }, #[cfg(all(feature = "webgl2", target_arch = "wasm32", not(feature = "webgpu")))] Msaa::Off, ``` Tested on `animated_mesh`, `many_foxes`, `custom_skinned_mesh`, Win10/Nvidia with Vulkan, WebGL/Chrome, WebGPU/Chrome. Note that testing `many_foxes` WebGL requires #18715.
As a side note, I really dislike the |
I have a branch that removes I've been sitting on it because I was hoping #18074 would land first and I wouldn't have to fix merge conflicts. But that PR looks like it's still got a long road to walk, so I'll make a PR now for |
|
## Objective Add a test that would have caught #16929 and #18712. ## Solution The PR adds a `test_invalid_skinned_mesh` example that creates various valid and invalid skinned meshes. This is designed to catch panics via CI, and can be inspected visually. It also tests skinned meshes + motion blur.  The screenshot shows all the tests, but two are currently disabled as they cause panics. #18074 will re-enable them. ### Concerns - The test is not currently suitable for screenshot comparison. - I didn't add the test to CI. I'm a bit unsure if this should be part of the PR or a follow up discussion. - Visual inspection requires understanding why some meshes are deliberately broken and what that looks like. - I wasn't sure about naming conventions. I put `test` in the name so it's not confused with a real example. ## Testing ``` cargo run --example test_invalid_skinned_mesh ``` Tested on Win10/Nvidia, across Vulkan, WebGL/Chrome, WebGPU/Chrome.
Objective
Fix motion blur not working on skinned meshes.
Solution
set_mesh_motion_vector_flags
can setRenderMeshInstanceFlags::HAS_PREVIOUS_SKIN
after specialization has already cached the material. This can lead toMeshPipelineKey::HAS_PREVIOUS_SKIN
never getting set, disabling motion blur.The fix is to make sure
set_mesh_motion_vector_flags
happens before specialization.Note that the bug is fixed in a different way by #18074, which includes other fixes but is a much larger change.
Testing
Open the
animated_mesh
example and add these components to theCamera3d
entity:Tested on
animated_mesh
,many_foxes
,custom_skinned_mesh
, Win10/Nvidia with Vulkan, WebGL/Chrome, WebGPU/Chrome. Note that testingmany_foxes
WebGL requires #18715.