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.

Dark GDK / The journey of speed, Static objects vs Animated Objects

Author
Message
Oneka
20
Years of Service
User Offline
Joined: 24th Apr 2004
Location: Hampton,VA
Posted: 25th Apr 2011 23:08 Edited at: 29th Apr 2011 03:13
NEW:

Updated this thread with the latest release libs of the work that has been done.

Source Code changes will be posted in thread

All of my changes will be signed with..


CObjectManagerC.cpp




OLD:


This purpose of the thread is to in the end result, make GDK/Darkbasic better and faster for everyone!

So this is the dilemma, it is a well known fact that static objects run faster than objects with animation data, but the reason for it isn't quite well known.

What I want to do, is either lead myself or maybe someone else to figuring out the root of this problem and fix it, I rather not move to another platform for various reason and I imagine that the problem isn't something that would be too hard to fix if dedicated person(s) took on the task.

So, heres a quick run down, I have noticed a performance drop in instances of a static version of a model vs an animated version, I could create about 256 versions of the static model (about 3.5k polys) into my engine and still get 100+ FPS, I use the same model but the animated version and the frame rate drops considerably, this is a problem, as I would imagine that just because an object has some animation data that it would still be able to run relatively the same speed especially when it is not being animated, but the mere existence of it causes a slow down, I believe this is somewhere within the rendering area of GDK/Darkbasic

I am not looking to use anything external as far as a plugin or related as I believe the problem can be fixed, though I am still peeking into the source of GDK to pinpoint where it is if you have any suggestions or information please let me know!

Let us work towards a better GDK/Darkbasic together, because its not THAT bad of a platform, just has some quirks that need to be worked out


Making dreams possible, one line at a time...

Attachments

Login to view attachments
Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 26th Apr 2011 00:53
I noticed this slowdown too:
dbPlayObject() issue?

TGC released the source so people could improve things like this, I think there have been a few improvements to the source code since then, although I have not been following it much.

You might want to look into dbSetObjectFrame() vs dbPlayObject() and see if there is an improvement.

I will certainly look into this issue if I get time, it might be useful if you give us some directions to the relevant code in the source and maybe give some information on anything you have found?

Oneka
20
Years of Service
User Offline
Joined: 24th Apr 2004
Location: Hampton,VA
Posted: 26th Apr 2011 01:14
Well I have been using dbSetObjectFrame() to do animation because the other commands do not work for me, but I have not really gotten anyway headway major yet but I will share as much info as I can


Making dreams possible, one line at a time...
JTK
14
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 26th Apr 2011 01:21
I'm intrigued myself. Since seeing your top post, I've been searching the forums for a reference to the latest "stable" release so I can get that code to work with. I'm not sure if r86 will do and I can't find any reference to the version that I currently have. I have not compiled the source yet, only use it to dig out the inner-workings so I can get an understanding of what's happening.

Post some source, both static and animated, and I'll try to compile and flesh it out. Who knows, maybe we can find the root cause.

JTK
WLGfx
17
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 26th Apr 2011 02:07
I personally have not used animated 3d objects, but saying that, if I had a choice of 'play anim' or 'set frame', I would probably use 'set frame' any way. For me it is just a habit and I like to know exactly where I am at every point. Well I don't want to know where I am really but I prefer my own anim handlers.

If the frame rate differs so much when using playobject, then I won't be using that command until there's a big fanfare announcing it's the new fam-dangled update.

I doubt I'd have a chance to benchmark this but I would like to see the results.

Warning! May contain Nuts!
Oneka
20
Years of Service
User Offline
Joined: 24th Apr 2004
Location: Hampton,VA
Posted: 26th Apr 2011 02:54
Yeah I really want to work towards fixing this issue because I love gdk and if we can fix this it helps it from being called "good for rapid development"

I have been doing my own work and release things to the community such as the load object and image from buffer commands


Making dreams possible, one line at a time...
Red Eye
16
Years of Service
User Offline
Joined: 15th Oct 2008
Location:
Posted: 26th Apr 2011 19:38
Does it have to do with the commands at all? Can't it just be a directx thingy? Like it is looping through certain properties while in animation mode. And if it is static it just renders, and doesnt loop through its properties.

Oneka
20
Years of Service
User Offline
Joined: 24th Apr 2004
Location: Hampton,VA
Posted: 26th Apr 2011 20:22
Well from what I understand at this time, it something about it having animation data, because I have taken the same model and make a static version and it ran so much faster where as the other one has animation data, even when I wasnt animating it, it still ran slower, in theory I think that such a major slowdown shouldnt exist when the model is just existing lol

But I will post some code soon, I have been busy with school, have exams next week, but

What my plan is,

Trace the code for the rendering process of the 3D portion of the engine and see where static objects and objects with animations begin to differ and we can discuss possible reasons / fixes


Making dreams possible, one line at a time...
JTK
14
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 27th Apr 2011 01:50
Tracing is liable to take a *long* time to sort out. If I had access to the debug-libs and example source, I could get us started by profiling the differences between the two. Once we can see which functions take longer, we can then look into the why do they take longer...

I'm having no luck building my version from the googlecode page...

JTK
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 27th Apr 2011 01:56
@Oneka
Are you using skinned meshes or "rigid body" animation? There is a big difference between the two.

Even without the stated "difference", anything that has animation is expected to--at any given time-- to be at an animation other than the original "static" form. This means that each frame it has to take a seperate matrix16 (the math version not db) for each "limb" and do rotation, location, and scale on it and then multiply it to the root frame's matrix16. If you want to get away from the "animation slow down" you would have to load seperate "static" versions of the animated object in each of it's animation frames and cycle through them during animation..... WOW! That would be a considerable amount of memory usage! It would be faster, but much larger.

Is the loss of FPS significant in your game? Or is it just something you were thinking might need another approach to improve performance?

When in doubt, look at my signature.....

The fastest code is the code never written.
Brendy boy
19
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 27th Apr 2011 02:53 Edited at: 27th Apr 2011 02:53
Quote: "This means that each frame it has to take a seperate matrix16"

Only if the animation frame changes

Quote: "Does it have to do with the commands at all? Can't it just be a directx thingy?"

It's not dx thingy. There's an axample that comes with directx sdk with animated skined mesh. I once created 100 animated meshes, where every mesh had different animation and they were all playing at once, and fps was way higher than the same example done in dbpro with only one animated mesh. So: 100 animated meshes compared to one and it still run much faster -> it isn't dx problem it's dbpro's/dark gdk's

Oneka
20
Years of Service
User Offline
Joined: 24th Apr 2004
Location: Hampton,VA
Posted: 27th Apr 2011 03:31
@Brendy boy, yeah you pretty much said it for me

@JTK, well I dont think the commands are the issue as the slow down happens way before the commands are even called, just loading the model with animation causes the huge slowdown way before any playobject or setobjectframe commands are called, its just that GDK/Dbpro handles them differently when the data just exists so that why I believe tracing down to the actual rendering portion may reveal the issue of it!

BTW what are the problem you have with compiling I can probably help you out with that


Making dreams possible, one line at a time...
Oneka
20
Years of Service
User Offline
Joined: 24th Apr 2004
Location: Hampton,VA
Posted: 27th Apr 2011 04:00 Edited at: 27th Apr 2011 05:34
Ok, I might have found something juicy, still reading through but this is located in CObjectManagerC.cpp



EDIT: I have found something useful in the
portion of code



This could be leading us right to our answer!


EDIT: After searching around some more, I believe the issue that we are having is not within the actual rendering code as I disabled object rendering and it still was slowdown, I think it is related to determining if the object is in screen and if so to render it code, that seems to be the plausible culprit!


Making dreams possible, one line at a time...
Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 27th Apr 2011 19:00
You could approach this differently, Blitz Terrain uses its own rendering function as does my plugin(Dark Imposters), its not too difficult.

Alsthough I understand it would be better to try and fix it from the source as everyone would benefit.

I may know more about this issue soon as I will be trying to render animated objects to a texture for my plugin, I will let you know if I find anything useful.

Oneka
20
Years of Service
User Offline
Joined: 24th Apr 2004
Location: Hampton,VA
Posted: 28th Apr 2011 04:51 Edited at: 28th Apr 2011 05:15
*A deep hum can be heard*

What is that I can hear?

I have had some success so far in making GDK/Darkbasic Pro faster with the existance of Animated Objects!

*cheers*



This is a picture from my game engine that I am working on, its not much in the scene and atm without anything but 1 object on the screen GDK runs at about 500fps for me, normally this scene with animated objects would be well under 30-40 frames but with my addition of code I have increase the speeds tremendously with animated objects, there is still much more work to go and I will post the codes as I get them in..but I was able to have over 100+ Objects all animated at the same time and still achieve frame rate of 100+ (Model is the Bandit from the store which is about 3-4k polys and is a 6.76mb file )


CODE:



My commented line for my work



EDIT: This code may or may not work with dbPlayObject() and related commands, PlayObject hasnt worked for me and I dont use it, I do my animations through the dbSetObjectFrame() commands, please test it and tell me if PlayObject is broken or not


EDIT: I just ran a test with 256 animated objects, got a FPS of 10 when animation process is running. Killing animation process brought fps to about 100+fps, this shows it is working as intended atleast right now because prior to code change, regardless of whether or not the object was being animated, if it had animation data it would run slow.


Making dreams possible, one line at a time...
Oneka
20
Years of Service
User Offline
Joined: 24th Apr 2004
Location: Hampton,VA
Posted: 28th Apr 2011 22:05
@matty halewood, I am curious as to how you use dbPlayObject as the command does not work for me (prior to my changes) and I wanted to make sure my changes did not break any existing commands


For those who cannot compile the libs, please let me know, I will supply my updated lib for you to test, they also contain some extra goodies that the normal ones do not so I hope you will enjoy them

Goodies:




Making dreams possible, one line at a time...
Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 28th Apr 2011 23:29
Good work Oneka.

I would not worry about breaking the dbPlayObject() command as its already broken

I dont use this command, I just noticed it never worked and assumed the update had not been tested so I switched back. Although I am switching to the update again soon to use Blitz Terrain, just not got around to it yet.

JTK
14
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 29th Apr 2011 01:11
@oneka: *me*, *me*, *me*! Could I request debug and release build versions? With source?

Post it here or you need contact info?

Regards,
JTK
WLGfx
17
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 29th Apr 2011 01:24
Nice! It would be nice if this would be part of the next update to the GDK download.

I keep watching these things and muddle through with what works for me, whilst people like yourself go and fix the broken or almost working parts.

Warning! May contain Nuts!
Oneka
20
Years of Service
User Offline
Joined: 24th Apr 2004
Location: Hampton,VA
Posted: 29th Apr 2011 03:08 Edited at: 29th Apr 2011 03:29
Updated first post with link to file / updated information, enjoy!

I plan to do some more changes and anything you may find let me know so I can possibly fix it, going to still work in the animation department to see if any further increases can be found!

EDIT: The increase in speed will come from the fact if you are not calling a change in animation then it will not perform transformations, so animate respectively and you will benefit (ie the less animations you do in a cycle the better, so for up close objects animate normally, far away objects can animate less)

EDIT2: If anyone has Enhanced Animations, let me know if you get even better results with it after this update!


Making dreams possible, one line at a time...
Oneka
20
Years of Service
User Offline
Joined: 24th Apr 2004
Location: Hampton,VA
Posted: 1st May 2011 23:21
Just giving you guys a heads up on what I am now currently working on

-Changed the way limbed objects work, before the system would make ALL limbed objects visible regardless if they were in view or not, changed it so that the limbs are only in view when the parent is in view

-Disabled g_Basic3D_AutomaticCollisionStart() for now until I get to it, basically it was being called every Sync() and would cause a drop in performance (This means that native GDK/DBP object collision more than likely will have been affected)

-Currently tackling the lots of objects = slowdown issue to help maintain a decent speed whether you have 1 object or thousands of objects


Making dreams possible, one line at a time...
Oneka
20
Years of Service
User Offline
Joined: 24th Apr 2004
Location: Hampton,VA
Posted: 2nd May 2011 23:35
-Another update if anyone is interested

I have made major headway into greasing up the engine better, I have now gotten even more FPS out of my scene, before it was under 50 or less frames, now its 170-210FPS with objects animating in them!



-Added a new command dbUpdateCameraFlag() this command with the way the rendering system now works will tell it that the camera has changed (rotation or position) and will updated it's render list, else it will render the same scene from the same stack, this increase performance

-Currently it does not support objects moving in or out of the scene
-Still working on code that determines objects visibility to increase performance too
-Working on a few more goodies for you guys!

-Working on a DBP port as soon as I can figure out how to compile for DBP..


Making dreams possible, one line at a time...
Neotron
14
Years of Service
User Offline
Joined: 21st Jul 2010
Location: I am in an underworld , making a E.Army
Posted: 11th May 2011 15:07
So nice stuff in here. By the if you are doing this animation thing ,
may i ask you if you could see the command dbsetlimbframe() or something that would animate the bone instead of the whole object.
Its gonna save alot of file size if you just check it out.
Cheers.

ALLAH IS THE GREATEST
May he forgive me
Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 11th May 2011 16:22
Hi Oneka,

Your game looks awesome by the way. Good to see you're making progress also.

Quote: "-Currently tackling the lots of objects = slowdown issue to help maintain a decent speed whether you have 1 object or thousands of objects"


Maybe there is a possible system that could be created without going into the source.

It seems to me that if you want hundreds/thousands of animated characters then you would need to use instanced objects. If for no other reason that each object having its own vertex/animation data would take up all available memory, then you have the speed issue if each objects has it own animation data updating all the time.

I'm pretty sure a system could be created where objects are instanced and share animation frames when they are far away, when they are close enough they could be switched for cloned objects, meaning you may only need 10-20 objects with unique animations.

It would not be easy to implement but if done properly could be a great speed/memory saver. Unless anyone can think of any unresolvable issues that this would throw up.

Oneka
20
Years of Service
User Offline
Joined: 24th Apr 2004
Location: Hampton,VA
Posted: 11th May 2011 18:16
@Neotron I will look into it

@matty halewood, thanks

I have actually done a few more fixes since the last time I posted, I just didnt update this thread so I didnt spam GDK forums as it seemed like not too many were interested in it


I will look into the setlimb function that you asked about Neotron and see whats going on with that.


Making dreams possible, one line at a time...
C++CPA+MBA
13
Years of Service
User Offline
Joined: 1st Jun 2011
Location: Charlotte, NC
Posted: 1st Jun 2011 12:36
@Oneka,

I am definitely interested in whatever you have codewise that speeds up FPS.

I am doing a game with a large terrain with tanks and planes that can stay above 60 FPS as is, but as I add more goodies, she is starting to slip below 60. I am using DEM data from the USGS to replicate my dad's property out in a rural area in the US.

When I die, I hope I don't go to DLL

Login to post a reply

Server time is: 2024-11-19 10:40:49
Your offset time is: 2024-11-19 10:40:49