Howdy
Tile map rendering is a simple topic that has been around since the beginning of game development, but what about rendering them efficiently?
The basic approach I've taken so far is:
- Created a sprite Batch (batch by texture i.e no state change for large groups)
- Use a texture atlas dds created from my custom dds compiler in the editor
- Render only the tiles that are visible on the screen.
- Each tile consists of 16 bytes per vertex : x, y, u, v
- All tiles vertices are calculated and stored in a big Vertex Buffer
- Drawn to screen
so some optimization that can be done:
- using index buffers to reduce 8 bytes per quad
- Some how use a single quad and transform it and change UV coords for each "instance"
The issue is a index buffer will be the same data over and over 0, 1, 2 0,2,3 (made that up) accept because its one vbuffer it will go up and up and up even though in reality there are only 4 vert's just the position and UV changes.
The idea of instancing seems good, but how do you handle the positions and the fact that your UV's are different for the tile Index into the tile atlas?
Any-who, whats the general consensus from the wise gray-beards of graphics programmers? :D
Thanks