Skip to content

Conversation

@andriyDev
Copy link
Contributor

@andriyDev andriyDev commented Dec 22, 2025

Objective

  • The glTF loader previously did two loads for textures: the first did all the expected parsing and loading. The second would intentionally try to perform the same load to A) avoid doing a second load, and B) to add the handle as a dependency specifically for the material - so that the material would not be "loaded with dependencies" until all its textures were loaded.
  • In general, it's possible for an asset to have a handle to another asset, without that handle being considered a dependency according to the LoadContext.
  • Also, some handles in the StandardMaterial were missing the #[dependency] attribute.

Solution

  • Add the dependency attribute to all handles in StandardMaterial.
  • Make the gltf anisotropy extension also use the parse_material_extension_texture function like all the other extensions (the existing implementation matched exactly).
  • Made LoadContext::finish update the list of dependencies with VisitDependencies.
  • Propagate the list of texture handles through the GltfLoader and clone the handle out when necessary.

Testing

  • Added tests to bevy_asset to verify tracking dependencies works - this also fails before the rest of this PR.
  • Ran the load_gltf example and it still works. This won't show whether the dependency tracking works correctly though.

@andriyDev andriyDev added A-Assets Load files from disk to use for things like images, models, and sounds S-Needs-Review Needs reviewer attention (from anyone!) to move forward A-glTF Related to the glTF 3D scene/model format C-Refinement Improves output quality, without fixing a clear bug or adding new functionality. D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes labels Dec 22, 2025
Copy link
Contributor

@ChristopherBiscardi ChristopherBiscardi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

read through the code and it all seems reasonable to me. +100 on the deduplication.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Assets Load files from disk to use for things like images, models, and sounds A-glTF Related to the glTF 3D scene/model format C-Refinement Improves output quality, without fixing a clear bug or adding new functionality. D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes S-Needs-Review Needs reviewer attention (from anyone!) to move forward

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants