Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Optimization Pro-Tips?

Author
Message
CumQuaT
AGK Master
13
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 7th Jan 2017 09:47
Wow, thanks Paul. Great to get a response from you. I'll try and address the things you've raised as best I can:

Quote: "you can use SetRawWritePath(GetDocumentsPath()) on Android to write to the SDCard"


That is super handy to know. Thanks for that!

Quote: "I assume the culling was for 3D tower objects?"


Correct. I don't actually use many sprites. Just UI stuff. Even my billboards are 3D plane objects as I couldn't get sprites to pass behind parts of the tower, etc. Made for a lot of fun doing animated textures, lemme tell you, but I got it working.

Quote: "Out of interest what culling method did you use?"


I'm using GetObjectInScreen, which I am told is the same as the default for AppGameKit, and yet I get better framerates when I do it myself to when I let AppGameKit handle it for me, which is perplexing.

Quote: "Are there a lot of transparent 3D objects?"


For the sake of performance, the entire tower is made of fully opaque objects. The only 3D objects which use transparency are the billboards I mentioned earlier - so all the monsters and particles. On these, I've purely used Alpha Masking to prevent any semitransparent particles and increase performance. Also the Alpha colour channel of all objects is set to 255. No fading occurs except in the UI sprites, of which there are few.

Quote: "how many different types of object are created an in what order?"


Actually a lot of objects. The tower is 12 segments around and 50 segments high. Each segment is a clone of one of eight object types which is then moved into place accordingly. None of the objects are animated. All movement around the tower is done by moving the camera, rather than the tower itself. The game makes no use of shaders whatsoever, and no custom lights are made to help the cartoon look of the game. Even all the billboards have their light mode set to zero.

I didn't realise, however, that the way you described it was how the rendering system of AppGameKit worked. It definitely gives me a little to mull over...

Quote: "use an atlas texture containing as many images as possible"


For construction of the tower itself, I do just this. Every tower object is textured from the same file (which makes loading in new purchased skins very easy). For all particles, monsters, pickups, etc, they each use their own individual texture, however, due to the number of frames in each one. All in all it leads to me loading in about 150 images to texture and animate everything in the game. I keep all of my files as small as possible, though, and 9 times out of 10 the game runs just fine. That being said, I could probably condense things further, especially with non-animated textures for things such as particles.

Quote: "all instances should be created together if possible."


It'd take a re-write of my tower construction module to make that happen, but it wouldn't be too tricky. That being said, the tower's assembly is done during the loading phase and not mid-game. The only things which are created mid-game are particles and the pick-ups in the game, and all of them are single polygon plane objects, so not really straining on the memory.

Quote: "If you want to get really advanced you can take over the 3D render order manually"


This may actually help a lot with the diagnosis of what's going on here... Thanks for that tip! My theory is that figuring all this stuff out on this game will make my development process on future games a lot smoother...

Hopefully my responses here are clear! If I can provide any other info then please let me know! I'm hoping to make this game be a little bit of an advertisement for AppGameKit, too, as I really think it's an amazing tool and want to get the word out.
CumQuaT
AGK Master
13
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 7th Jan 2017 11:38
So with my diagnostic tool I've been building, I've found that when the slowdown happens, the following stats change in the following ways:

GetFrameTime() increases by approximately x2
GetDrawingSetupTime() stays roughly the same. Goes up a little bit on average, but nothing mindblowing
GetDrawingTime() however, goes up by x5
and finally GetUpdateTime goes up by x5 as well

I tried disabling all particles and all billboards (all monsters, pickups, clouds, etc) and removed the one lone animated 3D model in the scene, and all I still get a similar result...

However, if I hide ALL of my tower objects, the slowdown disappears, even if all of the billboards, animated monsters and particles are left in place.

So at least I've narrowed down which part of the scene is causing the random slowdown. Just strange that it only happens SOMETIMES and not all the time!
damothegreat
User Banned
Posted: 7th Jan 2017 11:49
Like I mentioned like before - only update objects / sprites that only viewable on screen.

So in a 3D world - your viewable screen say is 1024x768 but objects that are way past these coordinates wont need to be updated

Like the skybox example where trees are wayyyyy in the distance and don't require any movements until they get 100yards to the player

Otherwise you be processing objects unnecessarily

so if objects

if x>0 and x<1024 and y>0 and y<768 then
process them
else
ignore them
endif

I maybe talking codswallop - but just to give an idea

Using Tier 1 AppGameKit V2
Started coding with AMOS
Works with a Lenovo IdeaPad 700, 1TB SSD (Data), 128GB HD (System), 12GB Ram, GeForce Nvdia 950M, Windows 10, 2.3Ghz (Turbo to 3.2ghz when required)
CumQuaT
AGK Master
13
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 7th Jan 2017 12:05 Edited at: 7th Jan 2017 12:05
Hi damothegreat, yeah we've been discussing the view culling earlier in the post and that is actually going on in the scene. It also doesn't explain why the issue is only happening some of the time, as the tower is always built with the exact same number of objects.
CumQuaT
AGK Master
13
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 7th Jan 2017 12:14
Currently I'm using 3DS files for the tower... I wonder if that might be causing it? I'll export them as X files and see if that helps.
Preben
AGK Studio Developer
19
Years of Service
User Offline
Joined: 30th Jun 2004
Location:
Posted: 7th Jan 2017 12:37
Hi CumQuaT,

I expect this mainly happen on your mobile devices , i tried many 3d leves in agk on mobiles and this sound like your running on the edge , many devices use shared memory and when your phone is also doing other stuff and it is , you might have these drops in fps.

For a easy test, do this:

Repleace ALL you LoadImage commands with

LoadImageResized( "", 0.5 ,0.5 )

If you still get a fps drop after this , well shared memory was not the case

best regards Preben Eriksen,
CumQuaT
AGK Master
13
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 7th Jan 2017 12:46
Hi Preben,

Thanks for the tip, but I've recently realised that the slowdown is being caused by the 3D objects in the scene. When they're all hidden, or not loaded at all, the slowdowns don't happen.

The objects all use the same atlas texture file, they are all cloned from the same set of eight models, and none of them are animated. They are frustum culled for occlusion and that's it, but if they're left out of the equation, then everything works fine 100% of the time. With them in there, perhaps 1 in 10 times that I run the app I experience a slowdown to about half speed.
CumQuaT
AGK Master
13
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 7th Jan 2017 14:01
I think I may have found it! I think it comes down to my occlusion system. Both mine and the in-built system were both missing a LOT of objects.

Just going to test this theory further and see if I can get the results I want to see... In the meantime, since this thread has gone to a hot topic, keep on posting those awesome optimization tips! This thread will hopefully help many future devs!
Preben
AGK Studio Developer
19
Years of Service
User Offline
Joined: 30th Jun 2004
Location:
Posted: 7th Jan 2017 14:06
I do not know what the tower objects is, do you have a screenshot ?

I guess you already tried the builtin agk debug function to see if you get any wierd errors, like wrong use of object ids etc.. ?

You say you clone , do the tower objects contain "multiply objects" or something special ? , try using instanceobject instead of cloneobject and see if it fix it.

If there is something special with the objects , try to use LoadObject on the tower, this normally fix any problems with special objects. ( if you currently use LoadObjectWithChildren ).



best regards Preben Eriksen,
CumQuaT
AGK Master
13
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 7th Jan 2017 16:17
It's all in the rest of the post (check the first page).

Tried instancing but it doesn't work, unfortunately. No errors come up in the agk error tool, either, as no errors are being hit - it's a performance issue. All of the objects are solid objects - no limbs, no multiple sub-objects. All fairly simple, unfortunately
CumQuaT
AGK Master
13
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 8th Jan 2017 15:08
RIGHT! So, I've fixed it finally and I figured I owe it to everyone to let them know what I did to fix the issue, since it was unexpected and tbh I'm not entirely satisfied with what I had to do to make it happen, but hey, it works, and it still looks great, so I can't complain.

Here's what I did:

- Removed all custom culling and went back to the AppGameKit default
- When loading in my atlas texture for the "tower", I loaded it in at 40% size
- I drastically reduced the number of "cloud" objects in the scene. Despite being simple plane objects, it ended up being quite a bit of 3D alpha masking for the game to render, which was causing a slowdown SOME of the time only because the clouds were generated randomly

Doing all of this has the game running fine on all my devices now.

Some things I did to try and diagnose this based on my own tinkering as well as a lot of help in this post (for posterity and future devs reading this):

- I first prevented key things from loading in the scene which I assumed to be the culprits, and started adding them back in one by one
- I did step 1 again, but this time with things which I DIDN'T assume to be the culprits, just to be thorough
- I seemingly narrowed it down to the tower objects, but didn't want to stop there, so I tried running the scene with all of the objects in place, but NO texturing. This increased the frame rate drastically
- That led to me trying to load in the tower texture file at a decreased size (despite the original not being that big, really) and getting a frame rate increase
- I then repeated steps 1 and 2 with the new texturing procedure in place. This hilighted that the clouds were causing slowdown in certain configurations
- I kept the cloud objects in there but removed all texturing and alpha masking. Frame rate went up, but not dramatically.
- Reduced the total number of cloud objects and increased their size so they still covered a decent amount of the sky for design purposes. Frame rate went up a little more.
- Loaded cloud textures in at reduced size. Frame rate went up a little more.

Final result I was not 100% happy with, but 90% happy with, and at this stage, that's plenty for me!

I hope this extensive post can help future developers seeking to optimize their projects!

Thanks again to everyone who helped!

damothegreat
User Banned
Posted: 8th Jan 2017 22:15
I'm happy you got it sorted
Using Tier 1 AppGameKit V2
Started coding with AMOS
Works with a Lenovo IdeaPad 700, 1TB SSD (Data), 128GB HD (System), 12GB Ram, GeForce Nvdia 950M, Windows 10, 2.3Ghz (Turbo to 3.2ghz when required)
CumQuaT
AGK Master
13
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 8th Jan 2017 22:57
Me too! Like a steering wheel down the pants this was drivin' me nuts!
damothegreat
User Banned
Posted: 8th Jan 2017 23:05
Its been a long debugging experience of game creating of which you will learn from.
Using Tier 1 AppGameKit V2
Started coding with AMOS
Works with a Lenovo IdeaPad 700, 1TB SSD (Data), 128GB HD (System), 12GB Ram, GeForce Nvdia 950M, Windows 10, 2.3Ghz (Turbo to 3.2ghz when required)
damothegreat
User Banned
Posted: 8th Jan 2017 23:06
But most importantly our teacher @Paul guided you in the right direction

Thanks Paul
Using Tier 1 AppGameKit V2
Started coding with AMOS
Works with a Lenovo IdeaPad 700, 1TB SSD (Data), 128GB HD (System), 12GB Ram, GeForce Nvdia 950M, Windows 10, 2.3Ghz (Turbo to 3.2ghz when required)
CumQuaT
AGK Master
13
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 9th Jan 2017 04:39
haliop_New
User Banned
Posted: 9th Jan 2017 11:06
I would recommend replacing 3ds files with obj files
I use about 1000 obj instance objects in my game and it runs well and most of them are alpha transparent .
give it a try I
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 9th Jan 2017 11:46
Good to hear to solved it, and thanks for the summary on how you got it fixed, very useful.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 9th Jan 2017 17:43
So the biggest issue was your custom culling?

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 9th Jan 2017 21:07
just found this commands , also useful for phones
ShareImage
ShareText
ViewFile
AGK (Steam) V2017.01.09 : Windows 10 Pro 64 Bit : AMD (16.12.1) Radeon R7 265 : Mac mini OS Sierra (10.12)
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 9th Jan 2017 21:25
Quote: "So the biggest issue was your custom culling?"


Sounded like the number of transparent clouds.
http://games.joshkirklin.com/sulium

A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
CumQuaT
AGK Master
13
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 10th Jan 2017 00:34
The biggest issue was the texture files. I didn't think them to be too large at around 1500x1500, but apparently they were. As soon as I brought them in a 40% size, the frame rate jumped up hugely. The other things like the culling and clouds only gave me a couple of extra FPS.
damothegreat
User Banned
Posted: 10th Jan 2017 18:25
Remember the picture sizes and memory consumption

12 + <width> * <height> * 4

1500 * 1500 * 4 = 9MB

If have tuns of these then woah will soon mount up

Say 10 images of this nature then that's a staggering 90mb that a poor little device will have to pull.

Glad you have decreased them and made better
Using Tier 1 AppGameKit V2
Started coding with AMOS
Works with a Lenovo IdeaPad 700, 1TB SSD (Data), 128GB HD (System), 12GB Ram, GeForce Nvdia 950M, Windows 10, 2.3Ghz (Turbo to 3.2ghz when required)
CumQuaT
AGK Master
13
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 10th Jan 2017 23:35
Actually only had the one. The rest of the textures are little things. The only one causing issues was one single atlas texture for all of the tower objects. So it wasn't a "lots of large textures" issue. It was a "one single large texture" issue.
Kevin Picone
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 11th Jan 2017 03:24
Quote: "
Remember the picture sizes and memory consumption
12 + <width> * <height> * 4
"


nah.. that's just AGK's format for users to tinker with, the device tends to pad textures whem imported, as this means the texture mapping routines can compute UV offsets in shifts, rather than multiplies.. When the texture gets big, the distance between texels can cause cache hits, which can really impact upon rendering performance.

PlayBASIC To HTML5/WEB - Convert PlayBASIC To Machine Code
CumQuaT
AGK Master
13
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 11th Jan 2017 03:37
As I learned!
haliop_New
User Banned
Posted: 11th Jan 2017 13:14
so when does this due ?
the unity version kinda sux my mobile fps
cant wait...
CumQuaT
AGK Master
13
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 11th Jan 2017 14:36
Yeah, we were VERY unhappy with the Unity output. The AppGameKit version runs fantastically well on all devices we've tested it on (including some fairly old ones!)

The only thing left for me to do is the minigame. Just tonight I finished writing a 3D sound module and put that in place to handle all of the fire spouts, tesla coils and angry chickens, and it all works really well. So I'll be starting on the minigame probably next week and then trying to get this sorted out by the end of the month. So expect a launch on iOS and Android sometime in February
haliop_New
User Banned
Posted: 12th Jan 2017 10:57
what kind of mini game ? and why is it needed ?
is it for between levels to get extra score ? like a bonus round ?
interesting...
Preben
AGK Studio Developer
19
Years of Service
User Offline
Joined: 30th Jun 2004
Location:
Posted: 12th Jan 2017 15:49
Yes its nearly always a matter of texture size:

Instead of this:


Your now loading in at 40% size , thats around 900x900 , but if you resize your texture in a image program to 1024x1024 and just use loadimage it will use the same amount of memory , so you get a bit more details.
Always use the nearest power of 2.

best regards Preben Eriksen,
CumQuaT
AGK Master
13
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 12th Jan 2017 22:05
Quote: "what kind of mini game ? and why is it needed ?"


It's a short little carnival game that is optional for the player. It allows them to a) have a relaxing break from the intensity of the main gameplay and b) win powerups, skins, more gold, etc, without using skill (just luck) so players who are struggling with the game can still get a reward. And yes, it's needed It's in the Unity version, too.

damothegreat
User Banned
Posted: 13th Jan 2017 00:09
Unity or other methodological Game development tools should not be mentioned here - its AppGameKit all the way
Using Tier 1 AppGameKit V2
Started coding with AMOS
Works with a Lenovo IdeaPad 700, 1TB SSD (Data), 128GB HD (System), 12GB Ram, GeForce Nvdia 950M, Windows 10, 2.3Ghz (Turbo to 3.2ghz when required)
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 13th Jan 2017 02:33
Considering that the talk is about converting a game previously made in unity *over to* AppGameKit, I wouldnt worry about it too much
http://games.joshkirklin.com/sulium

A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 13th Jan 2017 02:34 Edited at: 13th Jan 2017 02:36
Forum weirdness double post.
http://games.joshkirklin.com/sulium

A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
CumQuaT
AGK Master
13
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 13th Jan 2017 04:07
Yeah I'm 100% done with Unity and fully converted to AGK. Considering I do game development as my full-time profession, that's a pretty big compliment to TGC I'm loving AGK. Can't wait to see how it evolves and changes as development continues.

Login to post a reply

Server time is: 2024-04-25 05:34:42
Your offset time is: 2024-04-25 05:34:42