Game Development Community

C'mon iTGB

by Matthew Harris · in iTorque 2D · 05/31/2009 (12:18 am) · 13 replies

Well here is the scoop.

I have one t2dshape3d object in my scene about 800 polygons. (I know you can have up to 7000+ polygons on the screen per frame before you are in uh oh land)

I have a background tilemap and foreground tilemap platforms. All textures being used are PVR (for the tilemap images and the 3d model's skin)

I have no behaviors enabled but the platform controls one on my player.

I get resting 17fps and a load time of 20 seconds.

This is unacceptable. I am using iTGB_SCRIPT_OPTMIZE target, networking disabled, I am getting the fps from enabling metrics("fps"); I don't know how they can call this 1.2 if a basic scene can't get at least 25-30fps!

Whats going on?

#1
05/31/2009 (1:35 am)
I profiled my iTGB app and this is the results. TSShapeInstance is at the top of the list.

%NSTime % Time Invoke # Name
22.812 23.037 12260 TSShapeInstanceRender

isn't ~23 too high to render one TSShapeInstance.
#2
05/31/2009 (9:51 pm)
I added some sprites to my screen as bad guys. Added a few behaviors, shootadv, timershootadv, takes damage, receive damage, wave.

The fps is at 9.0fps in the beginning. When the bad guys come on the screen it drops to 6 fps. And when i shoot I get anywhere from 0.7fps to 3fps. This is when I run it off my phone with the profiler disabled on Target_Optimize_Script. Unplayable.

I hope 1.2.1 and 1.3 fixes these frame rate issues :(
#3
06/01/2009 (6:32 am)
Can you tell me your performance without the 3d shape, and can you tell me the tilemap resolution you are using? (i.e. 12x12?)
#4
06/01/2009 (2:11 pm)
@Helk

Well our background tile is 25x8 with 80x80 size tiles. That shouldn't matter it should only be rendering the tiles visible. The actual texture res we are using is 128x128. We have a few foreground tile maps.

The fps is 30fps. (taking everything out but the tile maps) which is what I want my final game to be with stuff like projectiles flying, one 3d shape, enemy sprites, basic particle explosions. All of this slows it down to 0.7fps.

I guess I can just release a tile map game and have people look at a static background.

- Matt
#5
06/01/2009 (3:09 pm)
I currently run with a 10x40 tilemap with 64x64 pixel tiles. I currently have approximately 24 different t2danimated sprites that are each 128x128 pixels in dimensions spread out over the map utilizing AI, astar pathing, and movement throughout the tile map while the main player can click/path to different locations and engage in RPG style combat. Each of these 24 creatures has a 16 frame t2dstatic sprite to display health status, 5 t2dtextobjects precreated added to the scene that become visible scroll upwards and fade out to show combat damage during combat. I also have several "gui" sprites layered on top of this with lots of transparency etc.

I consistently get 30-32 frames per second with it dropping to about 25-29 when I open up the 256x256 transparent inventory with 30+ 32x32 pixel t2dstaticsprite layered again on top of this.

The game performs very well from experience so it's either the t2d3dshape or some other aspect of the way your developing your game causing the problem. I'd suggest trying a few different things to narrow down the problem.

#6
06/01/2009 (3:18 pm)
Hey thanks bret,

I do think its t2dshape3d, (I am rendering a 620 poly player with a 200 poly gun mounted - this is the lowest lod of the model) I am going to see if I can speed it up t2dshape3d.

I two main reasons I use t2shape3d is because I can easily have 12 or so animations play and I can him face whatever direction by changing the rotation of the tdshape3d. Also because I don't quite understand the art pipeline for dts and my model pack I am using had a dts weapon and dts player, I made it so I can mount dts shapes to dts mount points of another model. It was the easiest way to "merge" the models.

- Matt
#7
06/01/2009 (4:41 pm)
Yea I'm really hoping you get the t2dshape3d working and running at an acceptable speed because I want to do something similar in my next game. Trying to find artwork for 2d animated sprites is difficult and expensive compared to 3d models which seem plentiful. Also sprites use a ton of memory and I've had to restrict my levels to 2 monsters + 1 player and animations only for north,east,west,south and no diagonals to keep memory consumption down. I tried adding the diagonals in this weekend but another 15 512x512 sprite sheets caused me to run out of memory. My sprites all have the following animations:
4 frames each direction for 16 frames total of 128x128 images. Each of these 16 frames fit in a 512x512 sprite sheet.

walk - north, east, south, west
combat ready - north,east, west ,south
attack - north,east ,west, south
pain - north, east, west, south
death - north,east, west, south


With 2 monsters and 1 player per level that's 15 512x512 sprites sheets which is quite a bit of memory in itself (262,144 * 4 * 15 = 15,728,640 !). With 3d models I could include a lot more different animations and really breath some life into the game.

Only problem is I find it hard to believe your going to get a decent frame rate on the iphone with a tile map, sprites, AND 3d models though I am certainly VERY much looking forward to being proven wrong!

Keep me up-to date on your progress, I'm very interested in doing 2d games with 3d sprites so I can have a lot of animations and variations for the animated portions of the game without the heavy memory overhead. Unfortunately I'm a total newbie when it comes to 3d so can't help you out.

BTW I have all my datablocks set to preload=true,filterpad=false, allowUnload=false because I noticed that without allowUnload=false there seems to be a lot of stutter. I haven't gone back and tested this since I've become more experienced with iTGB so it might of just been inexperience at the time.
#8
06/01/2009 (5:02 pm)
@Matt btw you might want to try making all your textures square and a power of 2, even if your not using PVR. I'm curious to see if that makes a performance difference or not because I've been very careful to make all my textures AND my cells within the textures square and a power of 2.
#9
06/01/2009 (5:08 pm)
Bret,

Yeah all my textures are a power of 2. PVR wouldn't work unless they were. And all my pngs (HUD items are power of 2 aswell) Its the golden rule.

You should look into a program called SpriteWorks made by John Kanalakis at http://www.envygames.com . Its a great program that converts 3d models to 2d sprite sheets. We bought it for use in our enemy sprites because they won't have a lot of animations.

I did some tests to make sure it wasn't my code that mounts a weapon dts to the player. I took out the rendering of it (a 200 poly weapon) and it is still the same fps. Then I tried just rendering the weapon and no player and got a slightly higher fps. (only two-three fps better).

I think pretty much any call to a t2dshape3d slows the engine down by nearly half (13-15fps). If someone can try loading a dts thats ~500-800 polys and test what fps they get in a basic scene I would love to know.

My dts(s) I am using are not problematic because they were art packs I bought from 3drt.com. I am pretty sure that guy knows what hes doing torque wise :P

I don't know where it stores the datablock for a t2dshape3d or where its stored in the project. I do have a TSShapeConstructor datablock for the model. But not sure where I can set preload, allowUnload etc for the shape. Maybe it doesn't exist. I am aware of managed.cs but nothing in there is relevant to my shape3d
#10
06/01/2009 (8:43 pm)
@Bret: I think your math is off. 512x512 images will take EVEN MORE than you calculated - one whole megabyte in memory ;)

An uncompressed 256x256 image (converted to uncompressed Targa to doublecheck) takes 256k. The PVR is only 32k. A 512x512 PVR is 128k - quite possible to fit a lot of animation even on an iPhone with that. If only it worked well.
#11
06/02/2009 (4:35 am)
The iPhone is drawcall limited. Every time a mesh is drawn you add a drawcall. Everytime a metarial on a mesh is changed you add a drawcall etc. etc.

At around 20-30 calls, the iphone has maxed out for that frame and you will start to see sharp performance degredation.

To make things work correctly on the device, you need to consolidate mesh draws and use a minimum number of textures. A lot of people have found that super textures are the way to go. These are basically large textures of say 1024 * 1024, that incorporate textures for multiple models. The you just use your UV co-ordinates to correctly texture models while not having to change materials.

The next thing to do is batch as many onscreen meshes as possible into a single draw call. The easy way to do this is to batch all meshes that use the same material into a single call. This is how I'm doing my 3D stuff, though the principal works just as well for textured quads (sprites).
#12
06/02/2009 (6:03 am)
@Ronny yea it's 512 * 512 * 4 which is what I used in my calculations, or 1 megabyte essentially. Since I have 5 animations per sprite that's 5 megabytes per sprite, which gives me a realistic maximum of 3 sprites if I want to be sure I never crash from out of memory problems. This is part of the reason why I'd like to move my sprites to 3d in my next game, I just don't want to take the huge time/learning curve hit right now to learn how to do 3d effectively.

If PVR worked on sprite cell sheets then I could possibly pack more sprites on the screen, assuming the quality drop was acceptable. So I'm really looking forward to PVR for Cell's in 1.3
#13
06/02/2009 (6:03 am)
ummm I have one mesh, one texture...