{"record":{"id":"dcf08bcb7f7d8000","repo":"bevyengine/bevy","slug":"too-many-triangles-triangle-count-in-an-emissi","errorCode":null,"errorMessage":"Too many triangles ({triangle_count}) in an emissive mesh, maximum is 65535.","messagePattern":"Too many triangles \\((.+?)\\) in an emissive mesh, maximum is 65535\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/bevy_solari/src/scene/binder.rs","lineNumber":428,"sourceCode":"\n    base_color: Vec3,\n    perceptual_roughness: f32,\n    emissive: Vec3,\n    metallic: f32,\n    _padding: Vec3,\n    reflectance: f32,\n}\n\n#[derive(ShaderType)]\nstruct GpuLightSource {\n    kind: u32,\n    id: u32,\n}\n\nimpl GpuLightSource {\n    fn new_emissive_mesh_light(instance_id: u32, triangle_count: u32) -> GpuLightSource {\n        if triangle_count > u16::MAX as u32 {\n            panic!(\"Too many triangles ({triangle_count}) in an emissive mesh, maximum is 65535.\");\n        }\n\n        Self {\n            kind: triangle_count << 1,\n            id: instance_id,\n        }\n    }\n\n    fn new_directional_light(directional_light_id: u32) -> GpuLightSource {\n        Self {\n            kind: 1,\n            id: directional_light_id,\n        }\n    }\n}\n\n#[derive(ShaderType, Default)]\nstruct GpuDirectionalLight {","sourceCodeStart":410,"sourceCodeEnd":446,"githubUrl":"https://github.com/bevyengine/bevy/blob/4805ca792c3e94eef07afd6fa9a2712f388c9a67/crates/bevy_solari/src/scene/binder.rs#L410-L446","documentation":"GpuLightSource::new_emissive_mesh_light (scene/binder.rs:418-424) stores the emissive mesh's triangle count in the u32 `kind` field shifted left by one bit (the low bit is the light-kind tag), leaving only 16 bits for the count. A single emissive mesh with more than 65,535 triangles therefore panics with the actual count in the message.","triggerScenarios":"Assigning an emissive material to any mesh with >65535 triangles while the Solari renderer processes the scene (indices.len()/3 above u16::MAX).","commonSituations":"High-poly GLTF imports whose materials are emissive; using emissive materials as decoration on dense scenery meshes; decimated-but-still-large models marked emissive.","solutions":["Split the emissive mesh so each part has at most 65,535 triangles","Use a simplified low-poly emissive proxy for the light and keep the detailed mesh non-emissive","Remove the emissive component from high-poly scenery that should not light the scene","Decimate the mesh below the limit"],"exampleFix":"// before — one 200k-triangle emissive mesh\ncommands.spawn((\n    high_poly_mesh,\n    StandardMaterial { emissive: emissive_color, ..default() },\n));\n\n// after — detailed mesh stays non-emissive, low-poly proxy emits the light\ncommands.spawn((high_poly_mesh, StandardMaterial::default()));\ncommands.spawn((low_poly_proxy_mesh, StandardMaterial { emissive: emissive_color, ..default() }));","handlingStrategy":"validation","validationCode":"fn tri_count(mesh: &Mesh) -> usize {\n    match mesh.indices() {\n        Some(indices) => indices.len() / 3,\n        None => mesh.count_vertices() / 3,\n    }\n}\n\n// before assigning an emissive material under Solari:\nassert!(\n    tri_count(&mesh) <= u16::MAX as usize,\n    \"emissive mesh too dense for Solari: {} triangles\",\n    tri_count(&mesh)\n);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check triangle counts of imported models before applying emissive materials","Use low-poly emissive proxies for lighting and keep detailed meshes non-emissive"],"tags":["bevy","solari","emissive","mesh","triangle-limit","pathtracing","panic"],"backgroundTag":"resource-limit-exceeded","analyzedSha":"4805ca792c3e94eef07afd6fa9a2712f388c9a67","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}