-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Add TilemapChunk rendering #18866
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add TilemapChunk rendering #18866
Conversation
Welcome, new contributor! Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨ |
Correct me if I'm wrong but I don't think |
e5de610
to
de7c7d0
Compare
@StarArawn good call -- updated to use a u32 texture instead. I think it may be better to use vertex attributes like you do with ecs_tilemap, but I'm not sure of the tradeoffs. I suspect using the vertex attributes and shader are necessary for making non-square tiles work? |
Here's a prototype 3rd-party crate that utilizes the changes here: https://github.com/ConnerPetzold/bevy_tilemap/tree/main/src |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a few comments, once those are fixed I think it will be good to merge.
Thank you for working on this!
tile_size -> tile_display_size
867d3ce
to
fe7fc55
Compare
|
||
/// A resource storing the meshes for each tilemap chunk size. | ||
#[derive(Resource, Default, Deref, DerefMut)] | ||
pub struct TilemapChunkMeshMap(HashMap<UVec2, Handle<Mesh>>); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be TilemapChunkMeshCache
to align better with other names in Bevy?
Objective
An attempt to start building a base for first-party tilemaps (#13782).
The objective is to create a very simple tilemap chunk rendering plugin that can be used as a building block for 3rd-party tilemap crates, and eventually a first-party tilemap implementation.
Solution
TilemapChunk
andTilemapChunkIndices
, and a new materialTilemapChunkMaterial
.TilemapChunk
holds the chunk and tile sizes, and the tileset imagetexture_2d_array
, with the assumption that atlases or multiple images would go through an asset loader/processor. Not sure if that should be part of this PR or not..TilemapChunkIndices
holds a 1d representation of all of the tile's Option index into the tileset image.Testing
tilemap_chunk
example, though I need to include some way to update indices as part of it.Showcase