englercj / phaser-tiled

A tilemap implementation for phaser focusing on large complex maps built with the Tiled Editor.
MIT License
290 stars 31 forks source link

Prerendering Chunks #14

Open englercj opened 9 years ago

englercj commented 9 years ago

An optimization should be to prerender static layers of the tilelayers to larger chunked textures.

This is really more help to canvas so it only renders a couple sprites each frame instead of however many there need to be on the screen based on tile size. For WebGL this might actually hurt performance in some cases since we are no longer using the same texture and just batching the sprites.

User should be allowed to turn on prerendering for a layer regardless of renderer, and also turn on prerendering only if the renderer is canvas.

anthonysapp commented 8 years ago

This would be a great enhancement! I am seeing a big performance drop on an iPad, and running in cocoon and I'm pretty sure this would help. Any ideas on how / where you'd implement this? I'm inclined to give it a shot if I can.

englercj commented 8 years ago

The idea would be to run through the map and draw chunks of it to different textures, then instead of using tiles for each of the map tile we render with the chunk tiles instead.

However, I think what I might do for v3 instead is drop the usage of sprites for tiles entirely and write custom rendering code. That way for webgl it is just a shader pass and for canvas I custom draw. I think I would get better perf that way. Even in that case it may still be nice to prerender chunks for the canvas implementation.