Optimizing maps and map rendering

The 2009 Mana project went dormant around 2014 and was revived in 2023; it currently develops a client implementation for TMW and potentially other games.


Post Reply
User avatar
Jaxad0127
Manasource
Manasource
Posts: 4209
Joined: 01 Nov 2007, 17:35
Location: Internet

Optimizing maps and map rendering

Post by Jaxad0127 »

Render optimizations have been discussed on IRC for the maps. I'll try to summarize what was said.
  • Rendering of all non fringe layers where all tile images used match the grid size can be optimized for the graphics hardware by not rending the tiles in (x, y) order but by rendering all tiles for a given tileset, then moving on to the next tileset and doing the same. This minimizes expensive texture swapping with no change in the resulting output.
  • We can also clear tiles on lower layers when upper layers completely cover them (100% opacity across the whole image). No need to draw what will be completely covered later in the same draw cycle.
  • A map preprocessor (that takes the original TMX files and output ones optimized for the first point) should be doable. All non animated tiles on non fringe layers can be merged into a two layers (one below fringe, and one above fringe) that uses a few constructed tilesets. The optimization from the second point would be handled here too.
There isn't much we can do to optimize rendering of the fringe layer, as it involves sprites and their untold image complexity, and a draw order that must remain (x, y) based.
Image
User avatar
o11c
Grand Knight
Grand Knight
Posts: 2262
Joined: 20 Feb 2011, 21:09
Location: ^ ^

Re: Optimizing maps and map rendering

Post by o11c »

I still think this would be better done like this: https://github.com/bjorn/tiled/issues/431

Nonetheless, it *is* possible to get rid of all layers but ground, fringe, and over entirely in the client.

For the Fringe layer, you *can* stitch together images in the same row.
Former programmer for the TMWA server.
User avatar
Jaxad0127
Manasource
Manasource
Posts: 4209
Joined: 01 Nov 2007, 17:35
Location: Internet

Re: Optimizing maps and map rendering

Post by Jaxad0127 »

o11c wrote:I still think this would be better done like this: https://github.com/bjorn/tiled/issues/431
I agree with what Bjorn said there. The preprocessor from point 3 would be part of the mentioned deploy step.
o11c wrote:Nonetheless, it *is* possible to get rid of all layers but ground, fringe, and over entirely in the client.
Animated tiles still present problems. An animated tile on ground layer 1 overlayed by a partially transparent tile on ground layer 2 presents issues. A preprocessor might be able to handle it nicely, though.
o11c wrote:For the Fringe layer, you *can* stitch together images in the same row.
True.
Image
Post Reply