droggelbecher / bevy-fast-tilemap Goto Github PK
View Code? Open in Web Editor NEWLightning fast tilemaps for bevy.
License: MIT License
Lightning fast tilemaps for bevy.
License: MIT License
I'm attempting to use this crate alongside a chunking implementation. To do so I wanted to make it so that each Chunk was a separate fast tilemap. However doing so causes all the other maps except for the first map to not be rendered correctly.
I copied the code straight from the examples for spawning my maps.
You can see based on the image that all the maps should be random like the first one however none of them actually are.
Code for spawning the tilemaps, used for each tilemap
// Create map with the given dimensions of our chunk
let map = Map::builder(
// Map size (tiles)
uvec2(
chunk.get_chunk_dimensions().x,
chunk.get_chunk_dimensions().y,
),
// Tile atlas
asset_server.load("tiles_16.png"),
// Tile size (pixels)
vec2(16., 16.),
)
.build_and_set(&mut images, |pos| rng.gen_range(0..15));
commands
.entity(entity)
.insert((
SpatialBundle {
transform: Transform {
translation: Vec3::new(
chunk.chunk_pos.x() as f32
* chunk.get_chunk_dimensions().x as f32
* 16.0,
chunk.chunk_pos.y() as f32
* chunk.get_chunk_dimensions().y as f32
* 16.0,
1.0,
),
..default()
},
..default()
},
ChunkMapSpawned,
))
.with_children(|parent| {
let mut map_bundle = MapBundle::new(map);
map_bundle.transform.translation = Vec3::new(
chunk.chunk_pos.x() as f32 * chunk.get_chunk_dimensions().x as f32 * 16.0,
chunk.chunk_pos.y() as f32 * chunk.get_chunk_dimensions().y as f32 * 16.0,
1.0,
);
parent
.spawn(map_bundle)
.insert(Transform::from_translation(Vec3::new(1.0, 1.0, 1.0)))
// Have the map manage our mesh so it always has the right size
.insert(MeshManagedByMap)
.insert(FastTileMap);
});
Great library. I'm render a Tiled
map and am unable to find any way to flip a tile on an axis. Does this a feature exist, or would implementing this feature be possible?
On Fedora Workstation, cargo run --release --example iso
(or any of the other examples) gets me:
thread 'main' panicked at 'Error in Surface::configure: Validation Error
Caused by:
Requested present mode Immediate is not in the list of supported present modes: [Mailbox, Fifo]
', /home/mattdm/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.16.2/src/backend/direct.rs:734:18
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Encountered a panic in system `bevy_render::view::window::prepare_windows`!
If I use WINIT_UNIX_BACKEND=x11
, they work fine.
hi,
is it possible to add some shader post processing to the tilemap or maybe use a custom implementation of tilemap_shader.wgsl?
All examples as-is render a pure red window. When I switch to perspective mode they render as expected.
I'm running MacOS Ventura.
Are there plans to support hexagon tilemaps?
So I am using this plugin to create a pretty big tilemap and I seem to have run into a very interesting visual problem. I believe it might be due to how the chunks are loaded for tiles but if I move around sometimes I can subtly see black lines go accross my screen. At first I thought that it was no big deal, but then I was walking around and randomly stopped on a spot where those black lines were covering the screen and they were staying there the whole time.
Maybe you can look into it, but in the meantime I will just ignore it.
I've been playing with this locally and wadding through a-lot of learning and wanted to create an issue to figure out if I'm heading in the correct direction/wasting my time because you're already working on this.
The simplest surface change from the shader context, looks to be changing the map_size to a vec3u, and adding a 'layer_padding/layer_offset' vec2f.
Will donate this asset and my example I'm toying with, has some magical numbers.
https://gist.github.com/urothis/ba9eb3930dcc481c84fd10a6fc8d4e86
I assume the ideal would be to not over-complicate with additional logic for tile determinism and leave that up to build_and_initialize.
You might have a bunch of tiles (a most obvious example is when your tiles are really cp-437 ascii in a roguelike) that you want to "tint". I see that you just added a feature for map attributes that sets a color, which it looks like applies more or less a color to the entire map? It would be nice to be able to apply colors to tiles independently.
I had a hand at a prototype by changing to store a struct in the storage buffer that contains the index and foreground and background colors. That could work .. but I also found it seemed to run things a bit slower. I am wondering what your thoughts are for including a feature like this in the library?
Out of curiosity, does it support 3D camera orthographic projection? I'm struggling on how to display it in the world. Any tips will be appreciated!
By the way, this crate seems to be awesome!
Hi!
i was trying to use overhang (perspective) to have tiles visually appear bigger.
for reference, we have those tiles:
to see it easier here is the same thing with a black grid:
each tile is 40x20, i used an overhang of
vec2(4. * TILE_SIZE.x, 4. * TILE_SIZE.y), // inner
vec2(2. * TILE_SIZE.x, 4. * TILE_SIZE.y), // lefttop
vec2(2. * TILE_SIZE.x, 0. * TILE_SIZE.y), // rightbottom
so basically
only 4 tiles (2 horizontal, 2 vertical) are shown of the palm.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.