Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/bevy_mesh/src/morph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_pbr/src/render/mesh_types.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct SkinnedMesh {

#ifdef MORPH_TARGETS
struct MorphWeights {
weights: array<vec4<f32>, 16u>, // 16 = 64 / 4 (64 = MAX_MORPH_WEIGHTS)
weights: array<vec4<f32>, 64u>, // 64 = 256 / 4 (256 = MAX_MORPH_WEIGHTS)
};
#endif

Expand Down
6 changes: 5 additions & 1 deletion crates/bevy_pbr/src/render/morph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.0))
.take(MAX_MORPH_WEIGHTS)
.copied();
uniform.current_buffer.extend(legal_weights);
add_to_alignment::<f32>(&mut uniform.current_buffer);

Expand Down