Tilemap Performance Questions

Discussion and feedback on Construct 2

Post » Tue Jun 02, 2015 6:24 am

Hi, I'm just starting to mess around with the tilemap, and I was wondering, right now my tilemap is about 80X60 tiles (@ 8px/tile) and if I move sprites on top of the tilemap the CPU usage spikes incredibly,.

This can be fixed by making the tilemap invisible and no other changes. Is this the normal performance?

I should say I have tried seamless mode off and it helps, but not much.
Follow me on Twitter @evgLabs
B
34
S
14
G
4
Posts: 251
Reputation: 4,074

Post » Tue Jun 02, 2015 10:48 am

What you described should not spike the CPU at all. You should provide a minimal .capx to prove this.
Scirra Founder
B
387
S
230
G
87
Posts: 24,248
Reputation: 192,228

Post » Tue Jun 02, 2015 3:38 pm

Hey Ashley,

Here's a capx for it https://www.dropbox.com/s/gc1zy56gaweucg9/marines%20test%20for%20cpu%20spike.capx?dl=0

I wasn't sure if it was something I was doing or not. Anyway, the way it is you'll see the CPU usage spike when the green circles are moving (In the task manager on my computer it maxes out a core) and if you click the button it'll make the tilemap invisible and you can see the CPU usage go down to practically nothing.

I hope it's either a simple fix or that I'm doing something stupid!

Thanks
Follow me on Twitter @evgLabs
B
34
S
14
G
4
Posts: 251
Reputation: 4,074

Post » Wed Jun 03, 2015 9:50 am

There is a pretty consistent high CPU usage across Chrome, Firefox and IE11, and all their profilers show it's spending all the time making WebGL draw calls. I suspect it's simply that you are using a very many small tiles. You have seamless mode off which helps, but you still have a huge number of 8x8 tiles with sections of alternating patterns, so there are no runs of the same tile. See How the WebGL renderer works: normally it can render entire regions of tiles with a single "set texture" then a single "draw quad" call, but alternating tiles forces a "set texture" then "draw quad" call per tile. With such small tiles and a large viewport you can fit in 100x100 tiles or 10,000 tiles on-screen, which gives you an idea of how much scope there is to hammer draw calls.

If nothing is moving in the layout C2 does not bother re-drawing the screen at all, which is probably the only reason you see higher CPU usage when things start moving.
Scirra Founder
B
387
S
230
G
87
Posts: 24,248
Reputation: 192,228

Post » Wed Jun 03, 2015 1:14 pm

Is it possible that a tilemap is faster if I use the tilemapeditor from Construct, instead I Import a tilemap with JSON?

I made the tilemap from the example above with Constructs own tilemapeditor and it seems that is a little faster.
B
2
Posts: 5
Reputation: 160

Post » Wed Jun 03, 2015 2:36 pm

@Erik101 - I doubt that makes any difference at all, if it renders the same tiles at runtime it's identical.
Scirra Founder
B
387
S
230
G
87
Posts: 24,248
Reputation: 192,228

Post » Wed Jun 03, 2015 3:23 pm

You're right, I just told the tilemap to set 100x100 of the same tiles and there was no noticeable performance usage. Thanks, I'll just have to change the way I'm doing it.
Follow me on Twitter @evgLabs
B
34
S
14
G
4
Posts: 251
Reputation: 4,074

Post » Wed Jun 03, 2015 4:43 pm

Hi @Ashley, I had a question about draw calls.
You mentioned that each alternating tile would have a separate draw call.
So, if we had a ground texture and wanted to add a variety of rocks in the dirt, would it be more efficient to have a tilemap with different rocks drawn on each tile, or one tilemap tile for just the dirt and have separate rock sprites placed over top?
Be sure to check out my Metroidvania game, A Hole in the Earth
B
59
S
24
G
3
Posts: 359
Reputation: 5,683

Post » Wed Jun 03, 2015 7:53 pm

ryanrybot wrote:Hi @Ashley, I had a question about draw calls.
You mentioned that each alternating tile would have a separate draw call.
So, if we had a ground texture and wanted to add a variety of rocks in the dirt, would it be more efficient to have a tilemap with different rocks drawn on each tile, or one tilemap tile for just the dirt and have separate rock sprites placed over top?


This is a great question; I'd also love to hear more about this. I've been using large, layered, mostly transparent tilemaps, painting unique details onto a "base" tilemap, and getting really high CPU usage.
B
20
S
5
G
3
Posts: 66
Reputation: 2,823

Post » Thu Jun 04, 2015 9:41 am

Scirra Founder
B
387
S
230
G
87
Posts: 24,248
Reputation: 192,228


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 5 guests