wgpu-tilemap
wgpu-tilemap is wgpu middleware for GPU-accelerated tilemap rendering, primarily targeted at 2d games.
It draws each tilemap as a single quad, so the vertex count is independent of the size of the tilemap. It uses texture arrays for the tilesets, so the fragment shader is essentially 2 texture loads: one from the tilemap and one from the tileset. It discards fully transparent fragments, so drawing multiple layers can be accelerated with a depth buffer.
Example
// Create a tilemap pipeline
let mut tilemap_pipeline = new;
// Specify a camera matrix
tilemap_pipeline.set_camera;
// Create/load a tileset
use Reader as ImageReader;
let tileset_image = open.unwrap.decode.unwrap;
let tileset = from_image;
// Upload a tileset to the GPU
tilemap_pipeline.upload_tilesets;
// Create/load a tilemap
let some_tilemap = zeroed;
// Upload a tilemap to the GPU
self.tilemap_pipeline.upload_tilemaps;
// Render the uploaded tilemaps
tilemap_pipeline.render;
License
wgpu-tilemap is licensed under the Apache License, Version 2.0, (LICENSE.apache2 or https://www.apache.org/licenses/LICENSE-2.0)