{"record":{"id":"3249e072dac1eecc","repo":"bevyengine/bevy","slug":"too-many-vertex-components-in-morph-target-max-is","errorCode":null,"errorMessage":"Too many vertex components in morph target, max is {MAX_COMPONENTS}, got {vertex_count}×{component_count} = {}","messagePattern":"Too many vertex components in morph target, max is (.+?), got (.+?)×(.+?) = (.+?)","errorType":"exception","errorClass":"MorphBuildError","httpStatus":null,"severity":"error","filePath":"crates/bevy_mesh/src/morph.rs","lineNumber":26,"sourceCode":"use thiserror::Error;\n\n/// The maximum size of the morph target texture, if morph target textures are\n/// in use on the current platform.\npub const MAX_TEXTURE_WIDTH: u32 = 2048;\n\n/// Max target count available for [morph targets](MorphWeights).\npub const MAX_MORPH_WEIGHTS: usize = 256;\n\n/// The maximum number of morph target components, if morph target textures are\n/// in use on the current platform.\n///\n/// NOTE: \"component\" refers to the element count of math objects,\n/// Vec3 has 3 components, Mat2 has 4 components.\nconst MAX_COMPONENTS: u32 = MAX_TEXTURE_WIDTH * MAX_TEXTURE_WIDTH;\n\n#[derive(Error, Clone, Debug)]\npub enum MorphBuildError {\n    #[error(\n        \"Too many vertex components in morph target, max is {MAX_COMPONENTS}, \\\n        got {vertex_count}×{component_count} = {}\",\n        *vertex_count * *component_count as usize\n    )]\n    TooManyAttributes {\n        vertex_count: usize,\n        component_count: u32,\n    },\n    #[error(\n        \"Bevy only supports up to {} morph targets (individual poses), tried to \\\n        create a model with {target_count} morph targets\",\n        MAX_MORPH_WEIGHTS\n    )]\n    TooManyTargets { target_count: usize },\n}\n\n/// Controls the [morph targets] for all child [`Mesh3d`](crate::Mesh3d)\n/// entities. In most cases, [`MorphWeights`] should be considered the \"source","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_mesh/src/morph.rs#L8-L44","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before: 800k-vertex sculpt with morph targets\nlet weights = MorphWeights::new(vec![1.0; 8], Some(handle.clone())).unwrap();\n// fails during morph texture build: TooManyAttributes { vertex_count: 800_000, component_count: 7_200_000 }\n\n// after: decimate the asset to <= ~465k vertices in your DCC tool, or split it\n// (e.g. separate head mesh with morphs, body mesh without)","handlingStrategy":"validation","validationCode":"const MAX_MORPH_VERTICES: usize = (2048 * 2048 / 9) as usize; // MAX_COMPONENTS / MorphAttributes::COMPONENT_COUNT\n\nif mesh.count_vertices() <= MAX_MORPH_VERTICES {\n    let weights = MorphWeights::new(weights, Some(handle.clone()))?;\n} else {\n    // decimate or split the mesh before adding morph targets\n}","typeGuard":null,"tryCatchPattern":"match MorphWeights::new(weights, Some(handle.clone())) {\n    Ok(w) => { entity.insert(w); }\n    Err(MorphBuildError::TooManyAttributes { vertex_count, component_count }) => {\n        bevy::log::error!(\"{vertex_count} vertices need {component_count} components > 2048x2048; split the mesh\");\n    }\n    Err(e) => bevy::log::error!(\"{e}\"),\n}","preventionTips":["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"],"tags":["bevy","mesh","morph-targets","texture-limit","vertex-count"],"backgroundTag":"vertex-limit-exceeded","analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}