Sanic Posted December 7, 2016 Share Posted December 7, 2016 I've been stress testing my browser to see how much I need to worry about optimizing my game in the future. When I load up a large Tilemap and zoom out (to jam as much of the map on the screen as possible before it crashes) chrome dev tools tells me most of the time spent per frame (and this is at 4 frames per second) is used up by numerous expensive calls to requestAnimationFrame() and hardly any time rendering in comparison. I'm just wondering if this is critical to call for tiles that don't animate? It doesn't seem so but I'm not sure if it's hooked into anything else that's critical. Link to comment Share on other sites More sharing options...
rich Posted December 7, 2016 Share Posted December 7, 2016 Think of raf as being the beating heart of Phaser. Every time it beats, it updates all of the internal systems, renders the scene and prepares itself for the next heart beat. Disable the heart, and you disable the entire game from updating, not just the animations. The cost is most likely just the rendering of the tilemaps (rather than raf itself), which are really slow under WebGL I'm afraid. Tilde 1 Link to comment Share on other sites More sharing options...
Sanic Posted December 7, 2016 Author Share Posted December 7, 2016 Chrome dev tools shows you if it's the render time that's taking forever. (This is just of what I'm working on now which is a graphics texture a small blank tilemap and some text, but the amount of 'rendering' wasn't much more than the amount of 'painting' seen below and the 'painting' wasn't any larger either.) Render time, at least on my machine, isn't a limiting factor is what I'm saying. So RAF is what keeps the game ticking over? I won't mess with it then, lol. But how are tilemaps being prepared per tick for WebGL? I've worked with OpenGL before and I know I've I've run into performance problems trying to send things like the entire buffer of tilemap vertices to the graphics card every frame... it wasn't immediately obvious why I shouldn't do that. And JS doesn't exactly give you tight control over how to store your data so that'd make it really hard to work with WebGL. samme 1 Link to comment Share on other sites More sharing options...
rich Posted December 7, 2016 Share Posted December 7, 2016 In WebGL it re-creates the texture every single frame (for the tilemap). We've got a new tilemap renderer available in its own branch, or you could use canvas, or there is Chads excellent Phaser Tiled plugin you could use. Link to comment Share on other sites More sharing options...
Recommended Posts