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.

Newcomers DBPro Corner / Two (seperate) slow down issues - help!

Author
Message
Sephnroth
21
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 15th May 2003 11:11 Edited at: 15th May 2003 11:19
Hi ^_^

I'm currently having problems in two areas, both resulting in slow down of one sort or another.

incidently, i didnt want to talk about both these things in the same post as it may lead to confusion ect ect.. but they are both pretty urgent to me and I didnt want to post this and then post another thing 2 seconds later.. seemed better to put them all in one, sorry if i shouldnt of :/

Problem A:

Literal game slowdown. My map editor is complete so i've started using it to make my maps (and also started creating more terrain models for it to use) - but already i've ground to a halt.. litrally. I decided to see what it could handle so I knew how liberal to be when making my maps, so i placed quite a large amount of trees down. It slowed right down to 23 fps.. but what is puzzling me is that it seems to be the amount of objects loaded rather than the amount of objects on screen slowing it down! To be honest, when I started whacking the trees in with no thought spared for my poor graphics card, i expected slow down. But i expected the kind of slow down that can be mapped around by say placing a big cliff through the center of my map to obstruct the view of half the objects and things like that, making sure that no matter how many objects i had they wernt all to be drawn at once. So, i made this test tree map.. loaded.. got the slow down i expected. I then turned the camera away from ALL the objects so it could only see blank space.. it still ran at 24fps T_T Any ideas why? I think there is roughly 400 objects in that map - if that truely becomes my limit then im in trouble, thats not really enough for me :/

**EDIT**
Forgot to mention, just incase anyone is wondering those trees are 72 polygons each (although like i said, polygon count doesnt seem to be the issue as I can look away from all the trees and it doesnt speed up at all)
**END EDIT**

Just incase your intrested:
http://www.spectural.com/storage/bts-slow.jpg
Ignore the dodgy first person view, the game is designed to be spent in 3rd person and i just added in that first person just now to get a better view of the map for a screen shot

Okay, now onto problem B..

This is about my map loading function. When i made my 400 tree map and then went to load it in the game engine, i noticed it took a little while to load (dont worry, thats expected and im not complaining about that ). I only used maps with 3 or 4 objects on for testing the engine upto now so i never noticed such loading times - but i decided right then, its time for a quick loading screen when maps are loading! Decided to do the works with a funky progress bar and percentage display. No worries there, it works fine - my problem is that it drasticly slows down the loading function

I decided to time it to see how much. Without loading screen the tree map takes 13.22 seconds to load, with the loading screen it takes 23.12 seconds, thats twice as long almost :/ and i think i know why, im just not sure what to do about it. I think its because of the need to use a sync command in the loading for loop to update the progress info - of course that forces the function to slow down to update the screen and what not.. I tried getting around this by setting the sync rate to 0 prior to uncap it for loading, didnt do squat :/ There has to be some way of doing a loading screen without killing the actual loading function? The reason why the loading screen is in the function is because i need to know how far through the map file it has got to calculate the percentage complete.. if anyone can help i would be SO thankful!

Heres the code for it (included as source for those who cant use code tags):



Dont worry about things that seem wrong, like DeleteObject() not being a dbp command - things like that are functions i wrote myself for the engine so i can load and delete objects without worrying about making sure its a free object number (function does that itself - loadobject returns the id it assigned the object to and delete object was written just to readjust vars used by loadobject)

ahh.. why are my posts always so long Im sorry guys :/ Will be most thankful for any help you can offer though

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 15th May 2003 11:47
SYNC RATE 0 and SYNCing every loop will make it worse. What you need to do is only sync once every 1 second or so. Or, alternatively, you could SYNC every 10% and only have 10 screen updates...

IF (p / 10.0) = (p / 10)
SYNC
ENDIF

This simple loop has the potential to not hit 10% increments exactly. You'd be better basing the calc on header.mapsize.

Thanks in advance.
All the Best,
StevieVee
sicjoshsic
21
Years of Service
User Offline
Joined: 8th May 2003
Location: United Kingdom
Posted: 15th May 2003 15:40
lol, for a slowdown its still going faster than my programs ever do (my radeon 9000 pro should soon fix that when i get it though )

Sephnroth
21
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 15th May 2003 17:00
Thanks Stevie for the loading bar comments ^_^ I did what you suggested and it increms in blocks of 10 percent now, reduced the loading time back down to 12 seconds

Now back to the speed issue about my object count.. i've been playing with ideas on how to speed it up (which is hard, as it seems to be a dbp limit and not my codes fault :/)... and i've been half successful!

My idea was that if it wasnt drawing all the polygons slowing it down and it was the object count then i had to lower this count somehow. LOL - not quite apiffiny of the year i know.. but let me finish 400 objects really isnt alot considering its just trees and i haddnt even filled a third of my 1800x1600 matrix terrain. If i was forced to stay to a lower object count than even that.. well it would of moofed my game over completly. But i thought.. hmm, maybe if they litrally are flagged as not there, db wont care about them no more? Did an experiment. Loaded all the objects as before, but used the hide object command on them all as soon as it was loaded. Sure enough, fps rockets streight back up to its 60fps cap
Right, so now i know i can hide objects to gain speed.. which is strange considering i can be looking in the oposit direction to them into the black void of "nothing here" and i dont gain no speed.. and i would of thought hide object and object not being in the camera fov should acheive the same thing (maybe dbp is behaving badly and drawing everything when it shouldnt?).. but whatever. My obvious decision was i need to look after what objects should be drawn and what shouldnt. So i knocked up this little function:

(TotalObjects is a global var maintained by my load/makeobject and deleteobject functions)



Tiny little thing isnt it.. produces huge results for something its size It did the job *almost* perfectly, if i turned my camera away it started hiding the correct objects and my speed stayed at its nice cap. Now the problem is that i could sit my tank at the bottom left of the matrix and look in the direction of the top right and well, object in screen would return them all as in screen and my fps drops again to its digusting rate :/ At first i gave this no thought saying "no problem, im gonna model some cliff terrain objects and things to place around the map to obstruct sections of the map to prevent you from looking at everything at once".. then i thought i better test the idea first. Did a simple make object cube and scaled it nice and big (heh, i mean big, at least along the x axis) to obstruct half the terrain, depending on which side of it you are you can see that half of the map.
Unfortunatly it returned the objects as still being "in screen" I guess technically they are and the in screen doesnt check to see if they are in screen AND actually visable. So thats what i now beg help for.. how can I detect if an object is truely visable? In the camera fov AND not obstructed by other objects? If between us we can make this function work it would be so good for just about any darkbasic game anyone would care to write (using 3d) - it gives a HUGE speed boost and allows for basically unlimited models loaded at any one time without slow down (as long as you map right to section off the map in places)! Cant be a bad thing?
I tried using Object Visible, but no go, it returned everything as visible wether it was off screen or on screen let alone wether it was obstructed or not ^^ I guess its returning the current hide/show object state rather than literal visibility.. ohwell.

Anyone have any ideas?

(sorry if i ranted again T_T)

sicjoshsic
21
Years of Service
User Offline
Joined: 8th May 2003
Location: United Kingdom
Posted: 15th May 2003 18:20
erm... sorry if this post sounds really stupid.

your idea that the game will run faster if it isn't drawing the polygons it can't see is right, but i don't think that just obstructing their view will do that, as (as far as i know) db draws things depending on their distance from the camera, dependent of the camera range. what i am getting at is:

use the Set Camera Range command to stop the program drawing the things it can't see

Sephnroth
21
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 15th May 2003 18:47
yes, i can severly limit the camera range (i havnt tried it yet though) - but im trying to avoid it, i like the nice big draw distance XD With a low camera range you start risking things like half objects showing and nasty clipping thingys. I already fog out the distance gently though.

But the point is, if I could just make my function do that last thing (it already works for literal fov, things behind you or too far to the left/right ect get hidden and not drawn) then there would be *no need* to limit the camera range. It would then be down to the map editor/designer (guess thats me ¬¬) to craft maps in such a way that things look good and fluid but also making good use of big terrain nodes (like cliffs, walls (ruin castle walls for eg)) to obstruct some parts of the map to save the processor there as the engine will then take care of drawing what it sees rather than, well, everything.

You get to keep your draw distance (which is fine, you could have a line of trees going off into the distance in a long line and dbp is fine with that, its when it starts trying to think about the other 100 on that side of the map that theres problems. So you obstruct things apart from that line - you get a big speed boost yet maintain a good illusion of vast, nonbreaking levels.

I belive the BSP system works simulary, gets it speed by only drawing what it can see - though bsp isnt right for what im doing. But it is needless (and even slightly stupid) to have your game engine worrying about objects the player cant see because they are behind something, am i making sense? ^^

sicjoshsic
21
Years of Service
User Offline
Joined: 8th May 2003
Location: United Kingdom
Posted: 15th May 2003 19:59
im not sure on how to help you with your function, but if you are using fog, then you really ought to make the camera range go to about 500 pixels behind the fog, because those things will never be seen through the fog anyway, and it will speed up the program if it knows not to draw them

Madehra
22
Years of Service
User Offline
Joined: 19th Sep 2002
Location: Portugal
Posted: 15th May 2003 23:03
OMG! :-s
It worked!
I changed the command sync in my game loop to the following line:

if timer()>loops+10 then sync : loops=timer()

In exclusive mode, it jumped from ~88fps to ~300!!!!!
the 88fps were acceptable, but in my brother's computer it was less than half, and in a friends computer it didnt go more than 15fps, I couldnt understand why since all I had was a rotating planet with cloud layer and stuff. Going to test this in my brother's computer now, i bet the results will be much better .
Sephnroth
21
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 16th May 2003 08:05
Sicjoshisic: I just performed a test and set my camera range to 50 so it wouldnt draw anything apart from what was right infront of it. I didnt even gain a 1 frame increase in speed
Its obviously not "whats being drawn" that is causing slow down.. just whats there :/ It is absolutly radiculous that setting all my objects to hidden gives me a giant speed increase but setting the camera range to draw nothing gives me none though.. Surley this isnt the way dbp is *supposed* to behave?! is it a bug with patch 4? I dont know, but until it gets fixed im going to have to find a work around myself.

I thought some more about how to work my object hiding function to take into account wether an object is obstructed or not.. only idea i can think of so far is a raycaster to cast a ray from object to player and the check at intervals along the line for an interruption.. but thats not very effcient, not very accurate and not very fast -_- Aynone else have any ideas?

Madehra: It does indeed give a speed increase, but that also gives very jerky movement (at least it does for my game), even when i set the +10 to +2 - but then again, even +2 will cut out half the updates

sicjoshsic
21
Years of Service
User Offline
Joined: 8th May 2003
Location: United Kingdom
Posted: 16th May 2003 12:21
ok, this is the last thing i'll say, since i obviously havnt understood the whole concept of speeding 3d up (the darkbasic help isn't very detailed, is it? )

you could try making the program hide objects that are behind the fog, then when they get near enough to you they are shown again. the only reason i say this is because you said you get a speed increase by hiding things.

if this is what your function was trying to do in the first place, just ignore me

Sephnroth
21
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 16th May 2003 12:39
lol No no, belive it or not you are being helpful ^_^ Any kind of input is always usful, helps to brain storm!

Hiding objects behind the fog is a good idea! However, fog in all honesty isnt too great. I only recently turn it on for laughs to see if it helps any (cant tell atm :/). Also, it doesnt fog distance.. it fogs objects. So im *guessing* if i started hiding objects, the fog would start disapearing *_* But you are on to a good thing as i have been pondering something very simular.
I already know how to get the distance between two points so i can tell how far away a object is easilly. I could just hide everything a certain distance away.. but i dunno, maybe im just being too picky when i say objects popping up out of no where looks a lil lame

But objects slowly fading in.. now thats what im thinking about. Objects fading in according to distance shows that the programmer at least tried to do something about popup fever (object aint there.. whoa, object suddenly is) I can code this as long as i find out how to do this to an object.. i was hoping the fade object command was my answer, but it isnt. HOWEVER, I do remember someone (kevil i think?) messing around with memblocks on one of the other dbp forums on this site and at the end of one of his last posts he said something like "and whilst doing this, i found you could set the transparancey value for each vertex on an object! you could use that to do things like teleportation effects" or something like that anyway So im now off to learn memblocks *gulp*

I read the 2d starfields with memblocks tutorial so i know how to perform pixel operations in the memory.. im now gonna go open dbp again and mess with that. Got an idea for screen brightness adjusting and possiably screen anti-aliasing in mind (but dont hold your breath) so im gonna go play with that just to settle into using memblocks and then i will investigate into how to mess on with objects and meshes with them. Heres hoping

While im doing this, please people feel free to continue replying to this thread with any other ideas on performance boosting! Im gonna squeeze every last fps i can out of this darn thing >.>

sicjoshsic
21
Years of Service
User Offline
Joined: 8th May 2003
Location: United Kingdom
Posted: 16th May 2003 12:52 Edited at: 16th May 2003 12:53
ok, if you Set Fog Distance 1000 (for example) and for the whole screen, not just objects
then you would have a function in your rogram that detects the distance of objects from you, and if they are less than 1500px from you, you tell the program to show them, if they are further, hide them.

that way, they won't appear out of nowhere (i agree, that is lame), because when they appear, you won't be able to see them because of the fog, and they will slowly fade in as you get closer and the fog moves behind them.

the 1000/1500 distances were just examples, you could have more than that if you want, i was just trying to show how i think you would do this (the easiest way)

[EDIT]:
try memblocks as well, apparently they are WAY faster if you can figure how to use them properly

Sephnroth
21
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 16th May 2003 14:08
haha, well - i managed to COMPLETLY screw up the pixel buffer XD Well, it kind of worked in a very strange way, but not really But thats besides the point, I went out to settle into memblock commands i got em down fine now ^_^ It screwed because my brightness altering was messed, but i fiddled the data fine ^^
Mind you, managed to make the "super fast memblocks" run at 4fps XD Guess it doesnt like performing an operation on every last screen pixel every frame... lol

Ahh well, im going to mess with a distance hiding thingy now like you suggested sicjoshsic. I'll just do the normal hiding objects for now, and maybe think about fading them after ^^

Oh, and just for laughs, heres one very messed up brightness modifier (or in this case, colour screwerupper) using memblocks XD



Sephnroth
21
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 16th May 2003 16:20
Okay, got a basic function working. It actually isnt too bad at all, tends to give me between 45-60 fps now depending where i am, what im looking at and just how many objects are around me I will probably cap the fps rate at 30 now instead of 60.. to stop nasty sudden speed ups when you happen to look where there is no objects compared to sudden slow down when there is.

For anyone who's intrested, heres the function. You need to setup a var (i use global) called DrawRange and set it to your desired range. I set DrawRange during engine initlisation and then set fog on and set the dog distance to = DrawRange - 500 so it slightly covers the objects that just got shown when you approach them (sicjoshsic's idea ^_^) to stop it from being so ugly.



Im actually still a little worried that at times i get 45fps.. i know thats plenty, but the point is theres only one special (and its not all that special) effect going on at the time. I was hoping to add all sorts of nice explosions and thingys.. but if i get this much trouble just with 400 72poly trees im in for a rough ride.. whats even more worrying is that i dont have a bad system either, my system is higher spec'd than the target systems i was aiming to devlop this for.. it wont be cool if you need to be nasa to run my game -_-

But oh well, i've done all i can for now. If i think up some miracle way to find if an object is completly obstructed by another then i can add that one final optimisation to hide those.

For now, im just going to model some terrain nodes, whack up a map, then im going to tweak the engine a little and put up a beta. I need to know how fast its running on other peoples machines early on before i start adding funky stuff -_- So i guess you guys can expect a beta soon (all depends on how long i decide to spend on modeling terrain nodes for my test map )

sicjoshsic
21
Years of Service
User Offline
Joined: 8th May 2003
Location: United Kingdom
Posted: 17th May 2003 01:42
glad i was of some use

Login to post a reply

Server time is: 2024-09-20 07:36:05
Your offset time is: 2024-09-20 07:36:05