bevyengine/bevy · critical
Too many light sources in the scene, maximum is 65535.
Error message
Too many light sources in the scene, maximum is 65535.
What it means
The Solari scene binder (scene/binder.rs:255-258) packs every light source — each emissive mesh light instance plus each directional light — into a GpuLightSource whose index must fit u16, so it panics when light_sources.len() exceeds 65535. The limit exists because light ids are addressed with 16 bits in the path tracer's buffers.
Source
Thrown at crates/bevy_solari/src/scene/binder.rs:261
this_frame_entity_to_light_id.insert(entity, light_sources.get().len() as u32 - 1);
raytracing_scene_bindings
.previous_frame_light_entities
.push(entity);
}
for previous_frame_light_entity in previous_frame_light_entities {
let current_frame_index = this_frame_entity_to_light_id
.get(&previous_frame_light_entity)
.copied()
.unwrap_or(LIGHT_NOT_PRESENT_THIS_FRAME);
previous_frame_light_id_translations
.get_mut()
.push(current_frame_index);
}
if light_sources.get().len() > u16::MAX as usize {
panic!("Too many light sources in the scene, maximum is 65535.");
}
materials.write_buffer(&render_device, &render_queue);
transforms.write_buffer(&render_device, &render_queue);
previous_frame_transforms.write_buffer(&render_device, &render_queue);
geometry_ids.write_buffer(&render_device, &render_queue);
material_ids.write_buffer(&render_device, &render_queue);
light_sources.write_buffer(&render_device, &render_queue);
directional_lights.write_buffer(&render_device, &render_queue);
previous_frame_light_id_translations.write_buffer(&render_device, &render_queue);
let mut command_encoder = render_device.create_command_encoder(&CommandEncoderDescriptor {
label: Some("tlas_build_command_encoder"),
});
let time_span = diagnostics
.as_mut()
.map(|diagnostics| diagnostics.time_span(&mut command_encoder, "tlas_build"));
command_encoder.build_acceleration_structures(&[], [&tlas]);View on GitHub (pinned to 4805ca792c)
Solutions
- Reduce the number of emissive mesh lights — they dominate the count
- Replace many small emissive objects with fewer merged/simplified emissive proxies
- Keep directional light counts minimal
- If the scene genuinely needs more, render it without Solari (standard mesh pipeline) instead of the path tracer
Example fix
// before — every bulb is its own emissive instance (100k light sources)
for i in 0..100_000 {
commands.spawn((bulb_mesh.clone(), emissive_material.clone()));
}
// after — one merged emissive strip provides the light, count stays under 65,535
commands.spawn((merged_strip_mesh, emissive_material)); Defensive patterns
Strategy: validation
Validate before calling
// Before enabling Solari, count emissive mesh instances + directional lights
fn assert_solari_light_budget(
emissive: Query<(), With<Handle<StandardMaterial>>>, // refine to emissive materials
directional: Query<(), With<DirectionalLight>>,
) {
let count = emissive.iter().count() + directional.iter().count();
assert!(
count <= u16::MAX as usize,
"Solari supports at most 65535 light sources, scene has {count}"
);
} Prevention
- Track emissive instance counts during procedural generation and cap them below 65,535
- Audit imported scenes for emissive materials before enabling the Solari path tracer
- Merge small emissive meshes so instances (not triangles) stay the scarce resource you manage
When it happens
Trigger: Enabling Solari rendering in a scene whose combined count of emissive mesh light instances and directional lights exceeds 65,535; heavy instancing of meshes with emissive StandardMaterial.
Common situations: Procedurally scattering tens of thousands of emissive bulbs/strips; CAD or archviz imports where many parts carry emissive materials; switching a dense scene from the standard PBR pipeline to Solari path tracing.
Related errors
- Too many triangles ({triangle_count}) in an emissive mesh, m
- Camera entity wasn't synced.
- Camera entity wasn't synced.
- Failed to calculate aspect ratio for Cluster: screen dimensi
- Cannot call `ReflectComponent::reflect_mut` on component {na
AI-assisted analysis of bevyengine/bevy@4805ca792c (2026-08-20).
Data as JSON: /api/errors/dd778e1d265044d8.
Report an issue: GitHub.