#render #vertex #batch #bevy #graphics

hephae-atlas

Hephae's texture atlas rendering and asset module

3 releases

new 0.2.2 Dec 17, 2024
0.2.1 Dec 16, 2024
0.2.0 Dec 16, 2024

#125 in Rendering

Download history 343/week @ 2024-12-13

343 downloads per month
Used in hephae

MIT/Apache

31KB
492 lines

hephae-atlas

Provides texture atlas functionality.

A texture atlas contains atlas pages, i.e. lists of textures packed into one large texture in order to reduce the amount of bind groups necessary to hold the information passed to shaders. This means integrating a texture atlas into Vertex rendering will significantly increase batching potential, leading to fewer GPU render calls.

This module provides the TextureAtlas type, which also derives Asset and has an associated asset loader with it. Refer to TextureAtlasFile for the specific format of .atlas files.

This module also provides AtlasEntry and AtlasIndex components; the former being the atlas lookup key, and the latter being the cached sprite index. The dedicated update_atlas_index system listens to changes/additions to texture atlas assets and updates the AtlasIndex of entities accordingly.

Ideally, you'd want to associate each atlas pages with a BindGroup, define a texture and sampler layout in the specialized pipeline, somehow store a reference to this bind group into the batch entities, and finally set the render pass' bind group to the atlas page bind group accordingly with the layout you defined earlier.

See the examples/sprite.rs for a full example.

Dependencies

~34–66MB
~1M SLoC