this is a tracking issue for integrating atelier-assets into bevy
I've been working with "resident asset-expert" @kabergstrom for awhile now to figure out the future of the Bevy asset system. @kabergstrom built atelier-assets, which has basically everything a pro-grade engine needs from an asset system. While learning atelier, I decided to explore the space for a bit by experimenting with directly expanding the current bevy_asset with the features we were interested in. After much discussion about adopting atelier-assets vs expanding the current system, we agreed that atelier was the best long term bet. We merged a subset of my "bevy asset rework" in #693, just to unblock scenarios like GLTF loading and to prepare the way for an atelier migration.
That being said, atelier needs a few features before it can be a drop in replacement for the current system. Atelier support shouldn't be merged until it has the following features:
bevy_asset integration layerAssetServer, Assets<T>, and Handle<T>. Zero-api breakage is a nice-to-have, but I'm cool with breaking apis if they are significant improvements or they significantly improve the integration clarity / complexity.Given that Bevy's current asset system works for most current platforms/user-facing scenarios, I don't want to merge Atelier until we are sure it won't significantly block progress on things like building out platform support or publishing games.
There are also some "nice to have" items that I won't necessarily block a merge on, but should be addressed as soon as possible:
And then there are some fun things that have no particular timeline and will likely just get spun off into their own issues:
Atelier currently uses Tokio, which does introduce a decent amount of dependencies.
I'm not sure about how stuck Atelier is on Tokio, but the smol async runtime is pretty amazing and ridiculously tiny. IMHO it's the best design for an async executor out there, but there could very well be reasons that Atelier can't swtich away from Tokio, and that's probably the topic of another thread.
Yeah we've talked a bit about that already. It's definitely on the table!
Eagerly waiting for the integration!
One note on wasm. While pack files are a simple option for small games, this would not work well for larger ones if each window refresh redownloads 1gb or more of assets. Larger web-based games use local storage to fetch assets just once. This would require some kind of cache layer, which looks for file in local storage and if it's not available uses HTTP to fetch it. If file-level caching is too difficult to implement, then maybe caching pack files would be easier (or just leave it up to the user to download it and provide in-memory file). But I believe with atelier "import and process before load" caching might be easy to implement. Which IIRC was one of the atelier goals to compile a fast asset storage optimized for production (without daemon). Maybe @kabergstrom could comment on this.
I'm not sure about how stuck Atelier is on Tokio, but the smol async runtime is pretty amazing and ridiculously tiny. IMHO it's the best design for an async executor out there, but there could very well be reasons that Atelier can't swtich away from Tokio, and that's probably the topic of another thread.
I want to move atelier-assets to bevy_task, which is based on crates also used by smol. There are a few things missing in bevy_task right now though, preventing the migration:
Would be happy if someone helped on these parts.
One note on wasm. While pack files are a simple option for small games, this would not work well for larger ones if each window refresh redownloads 1gb or more of assets. Larger web-based games use local storage to fetch assets just once. This would require some kind of cache layer, which looks for file in local storage and if it's not available uses HTTP to fetch it. If file-level caching is too difficult to implement, then maybe caching pack files would be easier (or just leave it up to the user to download it and provide in-memory file). But I believe with atelier "import and process before load" caching might be easy to implement. Which IIRC was one of the atelier goals to compile a fast asset storage optimized for production (without daemon). Maybe @kabergstrom could comment on this.
I think web distribution can be done in a ton of ways, and hopefully it'll be simple to implement different approaches. Would love contributions on this front. The Loader API (LoaderIO) is here:
https://github.com/amethyst/atelier-assets/blob/indirect_handles/loader/src/io.rs
For the packaging step, you can imagine just a function that takes &[(AssetMetadata, ArtifactMetadata, Vec<u8>)] and outputs whatever is loaded by the LoaderIO impl.
I would be interested in helping to port current loaders to atelier-assets. Has this effort started? If not, where should it be hosted?
I started on an integration here: https://github.com/kabergstrom/bevy/tree/master/crates/bevy_atelier
It's based on pre-asset-rework code though, so might want to just start over.
If you want to help with porting loaders, you can probably pull in atelier-assets as a dependency and port them to work with the Importer trait.
Most helpful comment
Yeah we've talked a bit about that already. It's definitely on the table!