• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Windows Working with many tiles slows down game?

K

Kerberos

Guest
Hey guys!

I upgraded to Game Maker Studio 2 recently and I have a big performance issue. I use a tile-system with lots of tiles with different depths because you should be able to walk ontop and behind them depending on the player's z-axis. I also implemented a heightmap system which creates these tiles. The problem is that the game drastically slows down if I use a lot of these in a room. I also implemented this system in Game Maker Studio 1.4 and I had no performance issues there because Game Maker 1.4 deactivates all tiles which are not visible.
Do you have any idea why tiles with different depths slow down the game so much? Maybe it's important to know that I don't add the tiles in the room editor but with code. If there is no solution I probably have to downgrade to Game Maker 1.4 again...

Thank you very much for your help!
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
How are you creating the tiles? Through code? Or by placing them on different layers in the room?
 
K

Kerberos

Guest
I create them with code because all of them should have a different depth. Otherwise my fake 2.5D effect won't work anymore. I think the problem is caused by all of the different tilemaps and layers I have to create...
The fps already drops if I fill the room with tiles like this:
Code:
for(var i = 0; i < room_width/16; i++)
{
   for(var j = 0; j < room_height/16; j++)  
   {
       depth_ = floor(random(-(room_height*2)/16));
       tile_layer = layer_create(depth_);
       tilemap = layer_tilemap_create(tile_layer, 0, 0, ts_tileset, room_width, room_height);
       tilemap_set(tilemap, 3, i, j);
   }
}
Isn't there any other way to work with tiles with different depths? In Game Maker 1.4 everything worked perfectly because I didn't have to create so many tilemaps.
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
How big is your room? How many layers are you making? My game Skein was faux-isometric and uses layers too, but I found that for most of the effects I wanted to create I only actually needed 2 tile layers, one for tiles that will be in front and one for tiles that are in the back... This is not something that's applicable to all games, however. Another WIP I have is doing pretty much the same as you are however, and I'm not noticing any FPS issues at all, even with 20+ layers with tiles... Have you rtun the game in the Debugger? You can then run the profiler and see exactly where the FPS bottleneck is...
 
K

Kerberos

Guest
Thank you for your quick reply!
I am literally forced to create an individual layer for almost each tile because they should be sorted by their depth: -y-z. The largest rooms should be about 500x500 tiles big because I want to make an openworld-like game.
I cannot say exactly how many layers I need to create but I think 800 layers is the maximum.
I don't have any objects with step-events in the room. The debugger says that "Finish_Frame" takes about 98% of the processing power.
 

LunaticEdit

Member
If you are creating a layer for each tile, you're talking about 250,000 layers. Each layer is most likely a draw call to the GPU, meaning your GPU is executing a quarter million draw calls per frame. At the VERY least, each tilemap would be 2 polygons, which would make it 500,000 polygons per frame, before any objects or effects are added in. I can imagine that slowing things down.
 

Yal

🐧 *penguin noises*
GMC Elder
The largest rooms should be about 500x500 tiles big
That's 250,000 layers, which is a pretty big number. I'm guessing each tile layer has optimizations of some sort, and doing individual layers for each tile will make you miss out on all optimizations.

Also, layers might generate a tilemap the size of the entire room even if you only use 1 tile. That could cause some sort of overhead (most notably you'll waste 250000 layers x 250000 tile slots of memory, which is a pretty effing huge number - memory is usually a bigger bottleneck than CPU).

Consider using asset layers instead, I'd say - they're basically GMS1 tiles. And if that fails, consider drawing the tiles yourself using a nested for loop so you don't need to store all the wasted data. Or maybe it would be possible to map them to a vertex buffer (3D model in GMS1 terminology) so you can offload all the overhead to the GPU after first loading it?
 
K

Kerberos

Guest
Thank you for your help!

What exactly do you mean with asset layers? I've never heard that before. Hmm... Unfortunately I really don't know so much about buffers and how to use them.
I really wonder why everything worked perfectly in Game Maker Studio 1.4. I think it's because Game Maker 1.4 doesn't have tilemaps and it deactivates tiles which are not visible/not in the view.
 

Yal

🐧 *penguin noises*
GMC Elder
What exactly do you mean with asset layers?
TLDR, GMS2 Asset layers are basically GMS1 tile layers. RT(F)M for the details, I don't use GMS2 enough to tell you how they work :p I'd imagine they're just straight ports of GMS1 tiles, but I could be wrong. (in particular, check whether you can place parts of sprites in them instead of just whole sprites)
 
K

Kerberos

Guest
Thank you for the reply!

Ah I see, you can create asset layers in the room editor but is there a way to create an asset layer with code?
 
N

NeZvers

Guest
I don't really know if that's possible but one option would be create tiles that are going to be visible (like 1 row around screen) and delete those that are further away. That could still cut into cpu but worth trying.
 
D

Deleted member 13992

Guest
I don't see why you need every tile to be its own layer, even in a 2.5D game. It sound like you are brute-forcing a solution for a problem rather than doing it elegantly.

Got a screenshot?
 
Top