bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
35.38k stars 3.49k forks source link

Texture atlas preprocessing & the art production pipeline. #13713

Open brandon-reinhart opened 3 months ago

brandon-reinhart commented 3 months ago

In order to make Bevy a tier 1 engine for 2D games, a better texture atlas art production pipeline is needed.

Requirements:

Additional Features:

Many of these are features of the Esoteric atlas packer, which is very good.

brandon-reinhart commented 3 months ago

Attacking this work probably breaks down into these steps.

  1. Research what needs to be done for "N-to-one" asset processing in assetv2. This means that a single output file is produced as a result of any file in a tracked directory changing (modify/add/delete). This may require a PR to file down any rough edges.

  2. Get preprocessing and loading working with basic bevy texture atlases using existing features and minimal or no metadata. So we can modify / add / delete and get a functional bevy texture atlas on the other end.

  3. Add the advanced configuration features once the simple model is in place and working. (probably a PR per feature)

msvbg commented 3 months ago

Related PR/issue: https://github.com/bevyengine/bevy/pull/11873 / https://github.com/bevyengine/bevy/issues/11634

clarfonthey commented 1 week ago

Found my way at this issue and wanted to just comment on a few low-hanging fruit I noticed.

First, TextureAtlasLayout includes a map from the atlas back to the original images, but this feels like a mistake. By itself, TextureAtlasLayout is a very simple structure that could be made de/serializable, but having asset IDs embedded directly inside it complicates things. IMHO, this should be instead delegated to another type, TextureAtlasSources, which is generated when an atlas is generated, but isn't needed if the atlas is loaded directly.

Second, while the TextureAtlasBuilder is nice, it feels like the majority of the settings for packing a texture atlas should be located in a struct which can also be de/serialized, so it can be used for the input to an asset processor.

Third, there could probably easily be a dedicated asset processor for texture atlases (there aren't any at the moment, but this could be the first!) based upon the above two types.

Finally, it's very weird that the type TextureAtlas doesn't refer to the entire atlas, but a texture on the atlas. It would make sense to have a TextureAtlas type storing the actual atlas asset (including the image), and an AtlasTexture to store the reference to the specific asset and an index.

Would be more than happy to implement a couple of these, after I look more into the code. Just figured I'd star the discussion before I do, since I think it's worth making sure I didn't misread anything.

msvbg commented 1 week ago

@clarfonthey I have largely worked around Bevy’s texture atlases to get something usable for my game. My current workflow is custom but pretty good! I agree with your raised issues, and there are even more problems. It might even warrant its own working group.