diff --git a/crates/benilla-assets/src/materials.rs b/crates/benilla-assets/src/materials.rs index e5b4d707..a901db3a 100644 --- a/crates/benilla-assets/src/materials.rs +++ b/crates/benilla-assets/src/materials.rs @@ -15,12 +15,23 @@ use bevy::render::render_resource::{ AsBindGroup, BlendComponent, BlendFactor, BlendOperation, BlendState, Buffer, ColorWrites, CompareFunction, RenderPipelineDescriptor, SpecializedMeshPipelineError, }; -use bevy::shader::{load_shader_library, ShaderRef}; +use bevy::shader::{load_shader_library, Shader, ShaderRef}; /// Compile the WGSL files into the binary and register them under /// `embedded://benilla_assets/shaders/…`. Call **after** Bevy's `AssetPlugin` (it fills the /// registry that plugin creates); [`crate::register_asset_loaders`] already does. pub fn register_shaders(app: &mut App) { + // The `load_shader_library!` calls below allocate a `Handle`, which bevy refuses + // ("the asset type has not been initialized") unless something has initialised the type. The + // render plugins do; an app that wants only the loaders has none, and on 0.18 that turned the + // six end-to-end pipeline tests red at once — a dependency's doing, invisible to the + // no-install gate because all six are data-gated and skip there. + // + // Guarded, because `init_asset` *inserts* `Assets`: calling it where the render + // plugins already ran would drop every shader they had loaded. + if !app.world().contains_resource::>() { + app.init_asset::(); + } bevy::asset::embedded_asset!(app, "shaders/terrain.wgsl"); bevy::asset::embedded_asset!(app, "shaders/wow_model.wgsl"); bevy::asset::embedded_asset!(app, "shaders/wdl.wgsl");