Skip to content

Asset Dependencies #26

Closed
Closed

Description

@cart

Currently assets can reference other assets via handles, but the Bevy asset system isn't aware of these dependencies. This hasn't really been a problem until now, but as we start making Bevy more event driven (ex: only updating an asset's RenderResources when the asset changes), this starts creating problems.

For example, when a ColorMaterial asset's referenced texture changes (same handle, different value) a new texture is created on the gpu and the old one is cleaned up because of the Texture AssetEvents. However the ColorMaterial RenderResources aren't updated to use the new RenderResourceId because the AssetRenderResourcesNode hasn't received a new ColorMaterial AssetEvent.

I think the right solution is to allow assets to enumerate their dependencies and use those dependencies to fire a new AssetEvent::DependencyEvent(AssetEvent) event. As AssetEvents are currently generic (AssetEvent) this clearly wont work for arbitrary dependency types.

The alternative solution is to handle depedencies on a case-by-case basis, but its hard to make that work for a generic abstraction like RenderResourceNodes.

Activity

  1. kabergstrom commented on Aug 10, 2020

    @kabergstrom

    Atelier-assets collects metadata about asset dependencies at Import-time by hooking into the Serialize implementation of Handle, meaning user code just needs to #[derive(Serialize)]. The system is fully aware of dependencies up-front, before any asset is loaded, which means dependencies can be guaranteed to be loaded before the asset itself. Metadata can even be analyzed offline or in-editor as the Import (parsing a source file and extracting assets) step is separate from loading the asset at runtime. Atelier-assets is designed with learnings from commercial asset systems like the one in Unity, and is built from the ground-up to work in an editor environment. PTAL and feel free to message me if you decide to have a closer look.
    https://github.com/amethyst/atelier-assets

  2. added
    A-AssetsLoad files from disk to use for things like images, models, and sounds
    C-FeatureA new feature, making something new possible
    on Aug 12, 2020
  3. cart commented on Oct 18, 2020

    @cart
    MemberAuthor

    This is resolved by #693 and will be even more resolved by the upcoming atelier-assets migration.

  4. added a commit that references this issue on Jul 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-AssetsLoad files from disk to use for things like images, models, and soundsC-FeatureA new feature, making something new possible

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions