diff --git a/crates/bevy_core_pipeline/src/motion_blur/mod.rs b/crates/bevy_core_pipeline/src/motion_blur/mod.rs index 3bb8ea3dba..11fc5fbe11 100644 --- a/crates/bevy_core_pipeline/src/motion_blur/mod.rs +++ b/crates/bevy_core_pipeline/src/motion_blur/mod.rs @@ -98,9 +98,9 @@ pub struct MotionBlur { /// Setting this to `3` will result in `3 * 2 + 1 = 7` samples. Setting this to `0` is /// equivalent to disabling motion blur. pub samples: u32, - #[cfg(all(feature = "webgl", target_arch = "wasm32"))] + #[cfg(all(feature = "webgl", target_arch = "wasm32", not(feature = "webgpu")))] // WebGL2 structs must be 16 byte aligned. - pub _webgl2_padding: bevy_math::Vec3, + pub _webgl2_padding: bevy_math::Vec2, } impl Default for MotionBlur { @@ -108,8 +108,8 @@ impl Default for MotionBlur { Self { shutter_angle: 0.5, samples: 1, - #[cfg(all(feature = "webgl", target_arch = "wasm32"))] - _webgl2_padding: bevy_math::Vec3::default(), + #[cfg(all(feature = "webgl", target_arch = "wasm32", not(feature = "webgpu")))] + _webgl2_padding: Default::default(), } } } diff --git a/crates/bevy_core_pipeline/src/motion_blur/motion_blur.wgsl b/crates/bevy_core_pipeline/src/motion_blur/motion_blur.wgsl index bcc0a35adb..e102d4c6b4 100644 --- a/crates/bevy_core_pipeline/src/motion_blur/motion_blur.wgsl +++ b/crates/bevy_core_pipeline/src/motion_blur/motion_blur.wgsl @@ -18,7 +18,7 @@ struct MotionBlur { samples: u32, #ifdef SIXTEEN_BYTE_ALIGNMENT // WebGL2 structs must be 16 byte aligned. - _webgl2_padding: vec3 + _webgl2_padding: vec2 #endif } @group(0) @binding(4) var settings: MotionBlur; diff --git a/crates/bevy_core_pipeline/src/motion_blur/pipeline.rs b/crates/bevy_core_pipeline/src/motion_blur/pipeline.rs index e9724ba6b4..7ad94d8874 100644 --- a/crates/bevy_core_pipeline/src/motion_blur/pipeline.rs +++ b/crates/bevy_core_pipeline/src/motion_blur/pipeline.rs @@ -113,7 +113,7 @@ impl SpecializedRenderPipeline for MotionBlurPipeline { shader_defs.push(ShaderDefVal::from("MULTISAMPLED")); } - #[cfg(all(feature = "webgl", target_arch = "wasm32"))] + #[cfg(all(feature = "webgl", target_arch = "wasm32", not(feature = "webgpu")))] { shader_defs.push("NO_DEPTH_TEXTURE_SUPPORT".into()); shader_defs.push("SIXTEEN_BYTE_ALIGNMENT".into()); diff --git a/examples/3d/motion_blur.rs b/examples/3d/motion_blur.rs index d6d3ddfe35..c0266fd681 100644 --- a/examples/3d/motion_blur.rs +++ b/examples/3d/motion_blur.rs @@ -7,8 +7,13 @@ use bevy::{ }; fn main() { - App::new() - .add_plugins(DefaultPlugins) + let mut app = App::new(); + + // MSAA and Motion Blur together are not compatible on WebGL + #[cfg(all(feature = "webgl2", target_arch = "wasm32", not(feature = "webgpu")))] + app.insert_resource(Msaa::Off); + + app.add_plugins(DefaultPlugins) .add_systems(Startup, (setup_camera, setup_scene, setup_ui)) .add_systems(Update, (keyboard_inputs, move_cars, move_camera).chain()) .run(); @@ -24,6 +29,8 @@ fn setup_camera(mut commands: Commands) { motion_blur: MotionBlur { shutter_angle: 1.0, samples: 2, + #[cfg(all(feature = "webgl2", target_arch = "wasm32", not(feature = "webgpu")))] + _webgl2_padding: Default::default(), }, ..default() },