From 7744ca5c322277eaef02a46f214972fe30741392 Mon Sep 17 00:00:00 2001 From: Luo Zhihao Date: Thu, 15 Jan 2026 22:38:42 +0800 Subject: [PATCH 1/2] Fix depth prepass with msaa on webgpu --- crates/bevy_pbr/src/render/mesh_view_bindings.rs | 8 +++----- examples/3d/decal.rs | 5 ----- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/crates/bevy_pbr/src/render/mesh_view_bindings.rs b/crates/bevy_pbr/src/render/mesh_view_bindings.rs index 579e6517e57f8..ae51490847c5f 100644 --- a/crates/bevy_pbr/src/render/mesh_view_bindings.rs +++ b/crates/bevy_pbr/src/render/mesh_view_bindings.rs @@ -369,9 +369,8 @@ fn layout_entries( )); // Prepass - if cfg!(any(not(feature = "webgl"), not(target_arch = "wasm32"))) - || (cfg!(all(feature = "webgl", target_arch = "wasm32")) - && !layout_key.contains(MeshPipelineViewLayoutKey::MULTISAMPLED)) + if cfg!(any(feature = "webgpu", not(target_arch = "wasm32"))) + || !layout_key.contains(MeshPipelineViewLayoutKey::MULTISAMPLED) { for (entry, binding) in prepass::get_bind_group_layout_entries(layout_key) .iter() @@ -733,8 +732,7 @@ pub fn prepare_mesh_view_bind_groups( // When using WebGL, we can't have a depth texture with multisampling let prepass_bindings; - if cfg!(any(not(feature = "webgl"), not(target_arch = "wasm32"))) || msaa.samples() == 1 - { + if cfg!(any(feature = "webgpu", not(target_arch = "wasm32"))) || msaa.samples() == 1 { prepass_bindings = prepass::get_bindings(prepass_textures); for (binding, index) in prepass_bindings .iter() diff --git a/examples/3d/decal.rs b/examples/3d/decal.rs index e81124275b2c5..13386b6e4e23b 100644 --- a/examples/3d/decal.rs +++ b/examples/3d/decal.rs @@ -2,7 +2,6 @@ //! Note: On Wasm, this example only runs on WebGPU use bevy::{ - anti_alias::fxaa::Fxaa, camera_controller::free_camera::{FreeCamera, FreeCameraPlugin}, core_pipeline::prepass::DepthPrepass, pbr::decal::{ForwardDecal, ForwardDecalMaterial, ForwardDecalMaterialExt}, @@ -47,10 +46,6 @@ fn setup( FreeCamera::default(), // Must enable the depth prepass to render forward decals DepthPrepass, - // Must disable MSAA to use decals on WebGPU - Msaa::Off, - // FXAA is a fine alternative to MSAA for anti-aliasing - Fxaa::default(), Transform::from_xyz(2.0, 9.5, 2.5).looking_at(Vec3::ZERO, Vec3::Y), )); From 4a9657688a037b3cb88a59be1012dd2e9f562029 Mon Sep 17 00:00:00 2001 From: Luo Zhihao Date: Mon, 2 Mar 2026 20:31:14 +0800 Subject: [PATCH 2/2] Update comment --- crates/bevy_pbr/src/render/mesh_view_bindings.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/bevy_pbr/src/render/mesh_view_bindings.rs b/crates/bevy_pbr/src/render/mesh_view_bindings.rs index 2d6c774b1cedb..cb7ef22122563 100644 --- a/crates/bevy_pbr/src/render/mesh_view_bindings.rs +++ b/crates/bevy_pbr/src/render/mesh_view_bindings.rs @@ -741,7 +741,8 @@ pub fn prepare_mesh_view_bind_groups( get_lut_bindings(&images, &tonemapping_luts, tonemapping, &fallback_image); entries = entries.extend_with_indices(((19, lut_bindings.0), (20, lut_bindings.1))); - // When using WebGL, we can't have a depth texture with multisampling + // When using WebGL, we can't have a multisampled texture with `TEXTURE_BINDING` + // See https://github.com/gfx-rs/wgpu/issues/5263 let prepass_bindings; if cfg!(any(feature = "webgpu", not(target_arch = "wasm32"))) || msaa.samples() == 1 { prepass_bindings = prepass::get_bindings(prepass_textures);