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 / Agk 3d performance (one large mesh compared to multiple small)

Author
Message
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 1st Jun 2013 10:46 Edited at: 1st Jun 2013 10:47
I started experimenting with creating my dungeon as a wavefront obj file.
And i whas suprised on the performance of agk when it renders it as a single object?

Could there be some things i missed when Writing my generator or is the differrence this large and why.

How does agk work when it comes to 3d rendering.

If this is right so should i maybe include walls also and not only floor and ceiling?



If this is right so maybe i should talk to van about rewriting large parts of the dungeon generator

Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz

Attachments

Login to view attachments
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 1st Jun 2013 11:09
with your 121 objects agk/opengl must calculate the vertex positions before,rotate/translate/scale.
(at pc with opengl it was possible to compile a sequence of opengl calls, this was useful for static objects.)
and maybe repeatedly called opengl functions slow down it.
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 1st Jun 2013 11:17 Edited at: 1st Jun 2013 11:18
the sad part is that i dont know until i try it in the Engine and that is a huge work.
The problem also seams to be that parts outside the camera range still is calculated on large objects?

Staretd to do the subimage texturing part so i can test a single large object inside the Engine to know for sure.
This is it randomly only use the top right corner of the texture on some parts.


Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz

Attachments

Login to view attachments
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 1st Jun 2013 12:56 Edited at: 1st Jun 2013 12:59
my test
it looks like than akg import a rectangle as two triangles.

Attachments

Login to view attachments
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 1st Jun 2013 12:57 Edited at: 1st Jun 2013 12:57
3d editor

Attachments

Login to view attachments
Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 1st Jun 2013 15:15
Hi Cliff, this is totally normal and I guess is the same on almost any engine.

I'm not too familiar with OpenGL but from DirectX experience I can tell you a few reasons why one large object is faster.

As Markus said, the world matrix will be recalculated for every individual object, but that's just the start. You also have render states being set for each object when they are all rendered with the same states. But the main reason may be that in the large object the same texture is used while with many objects agk may not recognise the same texture is used and it could be(probably is) changing texture for every object, this is a massive overhead.

So make your objects as large as possible, even group objects with different textures together into one texture and render as one object.

But remember the power of culling, not drawing something takes no time at all

So it's a pay off between large objects(single texture) and culling, somewhere there is an optimum size for objects which will give the quickest results.

Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 1st Jun 2013 20:07 Edited at: 1st Jun 2013 20:19
Thanks markus and matty

My biggest suprise whas mostly that the differrence whas this extreme.

But i know that some coding sites even writes that open gl dont like to create small objects either but you should Always try to create your objects large and then scale them down.
It where something about how some arm cpus calculate floats as large objects where easier for them to internally convert to integers?

But anyway i will give this a go and try it
Check van and my dungeon game page in the showcase for the progress
cheers.

Ps..
markus all mobiles wants triangulated objects thats why agk do this on all imported objects

I even Think after this that all my tilebased 2d games will use something like this for the tiles now when i know how to do it

Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz
swissolo
14
Years of Service
User Offline
Joined: 9th Jan 2010
Location:
Posted: 1st Jun 2013 20:35 Edited at: 1st Jun 2013 20:35
AGK automatically culls off screen objects correct?

swis
Joined: Tue Dec 16th 2008
Interstellar
Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 1st Jun 2013 21:12 Edited at: 1st Jun 2013 21:13
I love your game by the way.

If I was making something like that I would combine all textures for a single part of the dungeon into a single image, even if some textures are repeated on multiple images.

You can then still have culling with the sections, but each section is mostly one object, floor walls, ceiling, even generic objects like barrels etc.

EDIT: @ swissolo - I don't think agk has object culling but I am not certain.

swissolo
14
Years of Service
User Offline
Joined: 9th Jan 2010
Location:
Posted: 1st Jun 2013 21:25
Quote: "I don't think agk has object culling but I am not certain."

Well there's this

But that's just for individual faces. I guess I just assumed it ignored off screen objects.

swis
Joined: Tue Dec 16th 2008
Interstellar
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 1st Jun 2013 22:40 Edited at: 1st Jun 2013 22:42
Quote: "AGK automatically culls off screen objects correct?"

Iam not sure it works as it should as a plane i create with only a front face in an text file have 2 pollygons while a plane in agk with culling on still have 4 ?

Agk also seams to send Everything outside the camera range to render also ?
Because why dont processed vertices decrease when i lower the camera range with less part visible ?

But agk is in development so there is things that shouldt be done yet

I also had huge problems with my own object as it seams to be mirrored when loaded somehow and took about 2 hours to figure that error out after a whole lot of cross mirroring in my object Creation
I didt notice this until i started to skip planes where there are no segments

Quote: "If I was making something like that I would combine all textures for a single part of the dungeon into a single image, even if some textures are repeated on multiple images"

van and i use a single 256x256 image for the whole dungeon
enemies have one image for each type
items one image
sprite gui one image
We are going to combine it better later on

Iam going thru this pain as i want to optimize our game to work on even more devices

Quote: "I love your game by the way."

Iam impressed by your Projects

Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz
Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 1st Jun 2013 23:07
Quote: "van and i use a single 256x256 image for the whole dungeon "


Perfect, that's half the battle.

Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 1st Jun 2013 23:35
The gain on mobiles seams minimal ?

I am going to check how i write each plane as a limb as i belive they are culled away in agk ?

But as they dont have animation implemented so do i not Think a limb system is implemented in agk ?

Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz
swissolo
14
Years of Service
User Offline
Joined: 9th Jan 2010
Location:
Posted: 2nd Jun 2013 00:54
Quote: "Iam not sure it works as it should as a plane i create with only a front face in an text file have 2 pollygons while a plane in agk with culling on still have 4 ?"

Hmmm maybe I didn't interpret it correctly, or maybe it's truly a problem. Maybe Paul will come along and be able to explain. It's a pretty vital feature.

swis
Joined: Tue Dec 16th 2008
Interstellar
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 3rd Jun 2013 18:22
As has been already stated, drawing one large object will be faster than drawing lots of small objects as AppGameKit has to setup each world matrix and then make multiple calls to OpenGL to draw, whereas a single large object has one world matrix and one draw call.

Quote: "AGK automatically culls off screen objects correct?"


Not yet, the 3D support is very basic at the moment.
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 3rd Jun 2013 18:40 Edited at: 3rd Jun 2013 18:43
Quote: "As has been already stated, drawing one large object will be faster than drawing lots of small objects as AppGameKit has to setup each world matrix and then make multiple calls to OpenGL to draw, whereas a single large object has one world matrix and one draw call."

So far does it seam like using multiple objects and a custom culling system seams to be as fast as a large object.
It where a bit disapointing after all the work put in to Writing a system to make mesh object with texture uvs and all

But then again so when its implemented in to agk to not proces stuff outside camera range so would this be even faster.

Currently so is the gain on mobiles 3-4 fps.
But the best part so far seams to be that the framerate is more steady and seams to play alot smoother.

But then again so do i love that agk pushed me in to Learning to code wavefront objects

I will give an update to more correct framerates when i have checked that Everything is bug free as i simply can have missed some things that makes it using large object not as optimal as it should ?

One cool feature would be to use this for 2d games where all tiles is rendered using a single large object file now when i know how to do it

The hard part where to convert and mirror my map Array correctly to get the object file i wanted

Maybe i should add something to the codebase later wher this is used for a tile map?

But the dungeon generation system is a bit to large and complicated and specific to share i belive.

Simply stated so is it the future of my Projects to generate objects i belive?

Is there any dates to when correct offscreen and culling will be added?


And i wanted it explained more closely by people that know how this works then guessing

And in wath state the 3d part of agk is when it comes to performance

And as i have stated many times Before so are i not an programmer but an happy hobbyist that do this for fun
I hack away code until something works and not Always understanding how i made it work

Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 3rd Jun 2013 18:45
Quote: "One cool feature would be to use this for 2d games where all tiles is rendered using a single large object file"


AGK already does this for sprites where possible. If you are using the same image on multiple sprites with SetSortTextures(1) then it will group those sprites into a single draw call making it a large object as far as the GPU is concerned.

Quote: "Is there any dates to when correct offscreen and culling will be added?"


After 108 is finished I think the 3D system is going to get some attention
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 3rd Jun 2013 19:02 Edited at: 3rd Jun 2013 19:04
Good to know

Iam trying to recreate the string bug in the other thread but no luck so far?

The weird thing is that if i Before creating the dungeon level do double sync().

sync()
sync()
create level.
gameloop start (using a while loop)
do all the ingame stuff
sync manually
gameloop end

save auto save file using a global value that is stored in the menue screen when selecting save slot.

clear all media.

the weird part is that sometimes do i get a crash telling me that it couldt save file ( r (large empty string part) .sav ) ?

when it Always should open and save them like this 1.sav - 3.sav.

cheers.

Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz
swissolo
14
Years of Service
User Offline
Joined: 9th Jan 2010
Location:
Posted: 3rd Jun 2013 19:37
Quote: "Not yet, the 3D support is very basic at the moment."

Oh. We certainly can make our own culling systems, but it surely won't be as efficient as something coded within AGK. Well hopefully it's something that can be added soon! Might have been good to have it in the survey, but I suppose it couldn't cover everything

swis
Joined: Tue Dec 16th 2008
Interstellar

Login to post a reply

Server time is: 2024-11-24 13:36:34
Your offset time is: 2024-11-24 13:36:34