Performance: Tile Maps or LOTS of sprites?
by Jason Cahill · in Torque Game Builder · 03/29/2006 (8:00 am) · 8 replies
For a hobby project I'm working on for my friends, I am creating a game with a full-screen, fixed camera. The level will contain up to 1500 "obstacles" which consist of small "1 1" unit blocks which are laid out in a regular grid. I need to use collision detection so that my other objects stop when they collide with the bricks.
My question is: Is there any performance advantage to using a Tile Map for this vs. 1500 Static Sprites? I'm particularly concerned about the performance of rendering and collision. For the latter, I'm thinking about creating a few, large invisible objects that are simply collision boxes to overlay my graphics. That way, even though I have some 1500 static sprites, I will only be doing collision tests against some 32 big rectangles.
But, I still wonder and worry about rendering 1500 of anything in T2D. I've read from other posts in here (from people that I respect) that T2D starts to fall over once you get above 300 - 400 sprites. Is that true for tiles as well? I'm not going to be fill rate limited, each tile is tiny, there's just a heck of a lot of 'em!
Advice welcomed...
My question is: Is there any performance advantage to using a Tile Map for this vs. 1500 Static Sprites? I'm particularly concerned about the performance of rendering and collision. For the latter, I'm thinking about creating a few, large invisible objects that are simply collision boxes to overlay my graphics. That way, even though I have some 1500 static sprites, I will only be doing collision tests against some 32 big rectangles.
But, I still wonder and worry about rendering 1500 of anything in T2D. I've read from other posts in here (from people that I respect) that T2D starts to fall over once you get above 300 - 400 sprites. Is that true for tiles as well? I'm not going to be fill rate limited, each tile is tiny, there's just a heck of a lot of 'em!
Advice welcomed...
About the author
#2
No obstacles in my level: average frame rate = 240
1250 obstacles (no collisions) rendered in a single tile layer: average frame rate = 214
1250 obstacles (no collisions) rendered as individual static sprites: average frame rate = 107.5
What's interesting here is the ActRender static in the Debug Info Banner:
No obstacles: ActRender = 2 (my two player sprites) correct!
1250 via Tile Map: ActRender = 3 DANG!
1250 via static sprites: ActRender = 1252
So, the answer WITHOUT collisions is: USE TILE MAPS! Unfortunately I can't test collisions because of the bug I posted last night, where tile collisions don't seem to be working quite right.
03/29/2006 (8:22 am)
OK, well I've answered my own question... jeez it's easy to prototype things in TGB!No obstacles in my level: average frame rate = 240
1250 obstacles (no collisions) rendered in a single tile layer: average frame rate = 214
1250 obstacles (no collisions) rendered as individual static sprites: average frame rate = 107.5
What's interesting here is the ActRender static in the Debug Info Banner:
No obstacles: ActRender = 2 (my two player sprites) correct!
1250 via Tile Map: ActRender = 3 DANG!
1250 via static sprites: ActRender = 1252
So, the answer WITHOUT collisions is: USE TILE MAPS! Unfortunately I can't test collisions because of the bug I posted last night, where tile collisions don't seem to be working quite right.
#3
03/29/2006 (8:32 am)
Just posted the fix to this bug :)
#4
1250 obstacles (collisions on each tile) rendered in a single tile layer: average frame rate = 165
1250 obstacles (collisions on each sprite) rendered as static sprites: average frame rate = 60
Either way, this is totally incredible! Melv -- hat's off to you sir! This is FAR better than I would have expected for an early adopter release.
03/29/2006 (9:28 am)
WOW! This is incredible. OK, so after applying the diff, here's the numbers with collisions on:1250 obstacles (collisions on each tile) rendered in a single tile layer: average frame rate = 165
1250 obstacles (collisions on each sprite) rendered as static sprites: average frame rate = 60
Either way, this is totally incredible! Melv -- hat's off to you sir! This is FAR better than I would have expected for an early adopter release.
#5
I was able to get about 2000 sprites before seeing any slow down that would affect "fast action" games.
If you use a lot of static or slow moving objects, you can get up to around 4000 sprites without any big visual impact.
03/29/2006 (1:35 pm)
@Jason, I did some perf tests on the newest beta 1.1, and it is much better than 1.0.2 was.I was able to get about 2000 sprites before seeing any slow down that would affect "fast action" games.
If you use a lot of static or slow moving objects, you can get up to around 4000 sprites without any big visual impact.
#6
03/29/2006 (2:22 pm)
Melv's got more tricks in his hat :)
#7
03/29/2006 (2:47 pm)
I bet... that guy is awesome!
#8
@Jason: I'm actually rather pleasantly supprised by your tile stress test numbers... 1250 @ 165fps is really good.
03/29/2006 (3:19 pm)
@Matthew: That's great news, a lightweight sprite would be sweet.@Jason: I'm actually rather pleasantly supprised by your tile stress test numbers... 1250 @ 165fps is really good.
Torque Owner Michael Woerister
I dropped the approach with sprites because they ate up much more memory than needed. I would use a tilemap. They are made for things like you want to do, I guess.