From d72f4860216dcf00eba86854fc79c7a8f8e8a77a Mon Sep 17 00:00:00 2001 From: robtfm <50659922+robtfm@users.noreply.github.com> Date: Mon, 6 Oct 2025 12:51:10 +0100 Subject: [PATCH 1/3] increase morph targets to 256 --- crates/bevy_mesh/src/morph.rs | 2 +- crates/bevy_pbr/src/render/mesh_types.wgsl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/bevy_mesh/src/morph.rs b/crates/bevy_mesh/src/morph.rs index 4b6d2f574323d..2cb39a31985cb 100644 --- a/crates/bevy_mesh/src/morph.rs +++ b/crates/bevy_mesh/src/morph.rs @@ -14,7 +14,7 @@ const MAX_TEXTURE_WIDTH: u32 = 2048; const MAX_COMPONENTS: u32 = MAX_TEXTURE_WIDTH * MAX_TEXTURE_WIDTH; /// Max target count available for [morph targets](MorphWeights). -pub const MAX_MORPH_WEIGHTS: usize = 64; +pub const MAX_MORPH_WEIGHTS: usize = 256; #[derive(Error, Clone, Debug)] pub enum MorphBuildError { diff --git a/crates/bevy_pbr/src/render/mesh_types.wgsl b/crates/bevy_pbr/src/render/mesh_types.wgsl index 4c85192ddd9a2..476391d6f8415 100644 --- a/crates/bevy_pbr/src/render/mesh_types.wgsl +++ b/crates/bevy_pbr/src/render/mesh_types.wgsl @@ -34,7 +34,7 @@ struct SkinnedMesh { #ifdef MORPH_TARGETS struct MorphWeights { - weights: array, 16u>, // 16 = 64 / 4 (64 = MAX_MORPH_WEIGHTS) + weights: array, 64u>, // 64 = 256 / 4 (256 = MAX_MORPH_WEIGHTS) }; #endif From 2cefd434d325c56e47757bc454cf9bd9ab4bb1a8 Mon Sep 17 00:00:00 2001 From: robtfm <50659922+robtfm@users.noreply.github.com> Date: Mon, 6 Oct 2025 16:48:49 +0100 Subject: [PATCH 2/3] force buffer to required size --- crates/bevy_pbr/src/render/morph.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/bevy_pbr/src/render/morph.rs b/crates/bevy_pbr/src/render/morph.rs index 75ddb03414682..157936cdd07de 100644 --- a/crates/bevy_pbr/src/render/morph.rs +++ b/crates/bevy_pbr/src/render/morph.rs @@ -127,7 +127,11 @@ pub fn extract_morphs( } let start = uniform.current_buffer.len(); let weights = morph_weights.weights(); - let legal_weights = weights.iter().take(MAX_MORPH_WEIGHTS).copied(); + let legal_weights = weights + .iter() + .chain(iter::repeat(&0)) + .take(MAX_MORPH_WEIGHTS) + .copied(); uniform.current_buffer.extend(legal_weights); add_to_alignment::(&mut uniform.current_buffer); From 3b33cc4c69164faec8f1549abe209b3f7c85c7fa Mon Sep 17 00:00:00 2001 From: robtfm <50659922+robtfm@users.noreply.github.com> Date: Mon, 6 Oct 2025 16:54:53 +0100 Subject: [PATCH 3/3] oops --- crates/bevy_pbr/src/render/morph.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_pbr/src/render/morph.rs b/crates/bevy_pbr/src/render/morph.rs index 157936cdd07de..c742c77300cc0 100644 --- a/crates/bevy_pbr/src/render/morph.rs +++ b/crates/bevy_pbr/src/render/morph.rs @@ -129,7 +129,7 @@ pub fn extract_morphs( let weights = morph_weights.weights(); let legal_weights = weights .iter() - .chain(iter::repeat(&0)) + .chain(iter::repeat(&0.0)) .take(MAX_MORPH_WEIGHTS) .copied(); uniform.current_buffer.extend(legal_weights);