bevyengine/bevy · error · MorphBuildError
Too many vertex components in morph target, max is {MAX_COMP
Error message
Too many vertex components in morph target, max is {MAX_COMPONENTS}, got {vertex_count}×{component_count} = {} What it means
MorphBuildError::TooManyAttributes (crates/bevy_mesh/src/morph.rs:26) is produced when building the morph-target texture (MorphTargetImage::new in bevy_render/src/mesh/morph.rs:59). Each vertex consumes 9 components (position, normal, tangent, each Vec3) and all of them must fit into a square texture of MAX_TEXTURE_WIDTH=2048 per side, i.e. MAX_COMPONENTS = 4,194,304. When vertex_count * 9 exceeds that, no 2D layout exists and the build fails.
Source
Thrown at crates/bevy_mesh/src/morph.rs:26
use thiserror::Error;
/// The maximum size of the morph target texture, if morph target textures are
/// in use on the current platform.
pub const MAX_TEXTURE_WIDTH: u32 = 2048;
/// Max target count available for [morph targets](MorphWeights).
pub const MAX_MORPH_WEIGHTS: usize = 256;
/// The maximum number of morph target components, if morph target textures are
/// in use on the current platform.
///
/// NOTE: "component" refers to the element count of math objects,
/// Vec3 has 3 components, Mat2 has 4 components.
const MAX_COMPONENTS: u32 = MAX_TEXTURE_WIDTH * MAX_TEXTURE_WIDTH;
#[derive(Error, Clone, Debug)]
pub enum MorphBuildError {
#[error(
"Too many vertex components in morph target, max is {MAX_COMPONENTS}, \
got {vertex_count}×{component_count} = {}",
*vertex_count * *component_count as usize
)]
TooManyAttributes {
vertex_count: usize,
component_count: u32,
},
#[error(
"Bevy only supports up to {} morph targets (individual poses), tried to \
create a model with {target_count} morph targets",
MAX_MORPH_WEIGHTS
)]
TooManyTargets { target_count: usize },
}
/// Controls the [morph targets] for all child [`Mesh3d`](crate::Mesh3d)
/// entities. In most cases, [`MorphWeights`] should be considered the "sourceView on GitHub (pinned to 396ca72708)
Solutions
- Decimate/remesh the model until vertex_count * 9 <= 2048*2048 (vertex_count <= ~465,922)
- Split the model into several meshes each with its own morph targets
- Drop morph animation for the oversized mesh and use skeletal animation instead
Example fix
// before: 800k-vertex sculpt with morph targets
let weights = MorphWeights::new(vec![1.0; 8], Some(handle.clone())).unwrap();
// fails during morph texture build: TooManyAttributes { vertex_count: 800_000, component_count: 7_200_000 }
// after: decimate the asset to <= ~465k vertices in your DCC tool, or split it
// (e.g. separate head mesh with morphs, body mesh without) Defensive patterns
Strategy: validation
Validate before calling
const MAX_MORPH_VERTICES: usize = (2048 * 2048 / 9) as usize; // MAX_COMPONENTS / MorphAttributes::COMPONENT_COUNT
if mesh.count_vertices() <= MAX_MORPH_VERTICES {
let weights = MorphWeights::new(weights, Some(handle.clone()))?;
} else {
// decimate or split the mesh before adding morph targets
} Try / catch
match MorphWeights::new(weights, Some(handle.clone())) {
Ok(w) => { entity.insert(w); }
Err(MorphBuildError::TooManyAttributes { vertex_count, component_count }) => {
bevy::log::error!("{vertex_count} vertices need {component_count} components > 2048x2048; split the mesh");
}
Err(e) => bevy::log::error!("{e}"),
} Prevention
- Keep morph-target meshes under ~465k vertices (vertex_count * 9 <= 2048*2048)
- Decimate sculpted assets in the DCC tool before export
- Split large models so only small parts (face) carry morphs
When it happens
Trigger: Loading or spawning a mesh with morph targets where vertex_count exceeds ~465,000 (4,194,304 / 9). The check fires before any texture upload, at morph target image construction.
Common situations: High-poly facial-rig or blendshape models from DCC tools (sculpted heads easily pass 500k vertices); decimation not applied before export; merging morph-target meshes together raising the vertex count over the cap.
Related errors
- failed to generate morph targets: {0}
- The number of vertices exceeds u32::MAX
- Bevy only supports up to {} morph targets (individual poses)
- unsupported primitive mode
- failed to generate tangents: {0}
AI-assisted analysis of bevyengine/bevy@396ca72708 (2026-08-20).
Data as JSON: /api/errors/3249e072dac1eecc.
Report an issue: GitHub.