|
2 registered members (JeyKey II, EvanTJ),
8,242
guests, and 1
spider. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Number of functions affect fps?
#421287
04/14/13 23:54
04/14/13 23:54
|
Joined: Apr 2005
Posts: 1,988 Canadian, Eh
DLively
OP
Serious User
|
OP
Serious User
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
|
Hi everyone.
I have a simple question. When I set an entities' flag to invisible, does the engine still process its faces?
Or in other words.. If I have 100's of models adding up to 10k+ polys but not all seen on the screen at the same time. If I set them to invisible when they are not in the cameras view does that help anything?
Thanks.
Last edited by DevoN; 04/15/13 18:06.
|
|
|
Re: Invisible flag
[Re: DLively]
#421289
04/15/13 01:40
04/15/13 01:40
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
No. When they are not inside the view frustrum they don't get culled anyways. So setting the INVISIBLE flag won't make them any more invisible than they already are. Chances are pretty high you make the situation even worse by optimizations of this kind.
Always learn from history, to be sure you make the same mistakes again...
|
|
|
Number of functions affect fps?
[Re: Uhrwerk]
#421334
04/15/13 18:05
04/15/13 18:05
|
Joined: Apr 2005
Posts: 1,988 Canadian, Eh
DLively
OP
Serious User
|
OP
Serious User
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
|
thank you Uhrwerk. Another question, do the amount of functions i have running effect my fps rate? my fps idles at 66 and then drops to 50 for a moment every once and a while.. I have many animated flower models each sharing an action. I have 666 (I dont like that number as much as anyone else does) functions running in my 1 level so far. is that not bad? terrible? average? Thanks guys! Love this forum 
|
|
|
Re: Number of functions affect fps?
[Re: DLively]
#421337
04/15/13 18:31
04/15/13 18:31
|
Joined: May 2009
Posts: 5,378 Caucasus
3run
Senior Expert
|
Senior Expert
Joined: May 2009
Posts: 5,378
Caucasus
|
Try to decrease that, it affects on the speed of course. F.e. use one loop, cycle throw all entities, find those animated flowers and stuff (use a skill for this, check it while cycling throw all entities via for loop), and animate with a single function. Plus, be aware to use loops correctly, so you don't call a function, which contains a loop, inside of the other loop f.e. that will lead that your number of functions will increase till you'll get crash/error or whatever.
Greets
|
|
|
Re: Number of functions affect fps?
[Re: 3run]
#421339
04/15/13 18:47
04/15/13 18:47
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
DevonN, please keep in mind that optimization is a higly complex topic. Statements as "666 actions are too much / ok" are almost always nonsensical, because it's the context that is important. A screenshot with the debug panel on it is absolutely required to draw any conclusions. Why are you even caring about optimization when your game runs stable at 50 - 60 frames per second?
Always learn from history, to be sure you make the same mistakes again...
|
|
|
Re: Number of functions affect fps?
[Re: Uhrwerk]
#421342
04/15/13 19:30
04/15/13 19:30
|
Joined: Apr 2005
Posts: 1,988 Canadian, Eh
DLively
OP
Serious User
|
OP
Serious User
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
|
I did try to decrease it by altering the action a couple ways. I am only using 1 loop and cycling the animation at 100%. On the other hand there are 2 if statements which check to see if the entity is on screen or not for LOD purposes. The reason that optimization is important to me now, is because I dont want to get further into my project an realize that I could have saved memory somewhere. THis way my project is optimized perfectly from 1 - 100% The reason my fps dropping from 66 - 50 is because I've created many projects before where my fps just dropped all of a sudden and never went back up.. ever. so the project was finished. I've wasted days trying to find a bug that isn't even findable it seems.. so now I take my time and make sure that my project is optimized all the time. And how can you say it runs stable? it lags like you wouldnt beleive. why anyone want their project to do that, in a common area of the game?  Statements as "666 actions are too much / ok" are almost always nonsensical, because it's the context that is important.
What do you mean by that?
|
|
|
Re: Number of functions affect fps?
[Re: DLively]
#421343
04/15/13 19:46
04/15/13 19:46
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
The reason that optimization is important to me now, is because I dont want to get further into my project an realize that I could have saved memory somewhere. THis way my project is optimized perfectly from 1 - 100% The reason optimization should be important to you is when there is an actual need for optimization. DON'T try to be smart about things and optimize anything that appears to be slow. If there is an actual performance bottleneck, track that down and optimize it (and do it by actually looking what is slow, not guessing). KISS is the concept you would most likely want to follow. Also, performance and saving memory are usually two contradicting things. You can speed an awful lot of things up by dedicating more memory to them, or you put some more work on the CPU and save memory in return. On the other hand there are 2 if statements which check to see if the entity is on screen or not for LOD purposes. This sounds like you are potentially doing more work than you should do. If something isn't on the screen, it is either clipped during the frustum check or send to the GPU and then discarded (don't worry about sending a few thousand polygons to the GPU, the bus is extremely fast and the GPU won't waste any fragment processing on invisible polygons)
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
Re: Number of functions affect fps?
[Re: DLively]
#421344
04/15/13 19:46
04/15/13 19:46
|
Joined: May 2009
Posts: 5,378 Caucasus
3run
Senior Expert
|
Senior Expert
Joined: May 2009
Posts: 5,378
Caucasus
|
I did try to decrease it by altering the action a couple ways. I am only using 1 loop and cycling the animation at 100%. I can't really understand this one.. On the other hand there are 2 if statements which check to see if the entity is on screen or not for LOD purposes. Can you explain this one as well? Why do you need to check, if entity on the screen or not? My solution, to have one loop for 666 (more/less) flowers and stuff:
void animateEnt(ENTITY* ent, STRING* scene, spd){
// change this skill here, if you use it somewhere else:
ent.skill1 += spd * time_step;
// animate the entity with a CYCLE (100 %):
ent_animate(ent, scene, ent.skill1, ANM_CYCLE);
}
void actGrass(){
// make me passable (speed up collusions):
set(my, PASSABLE);
// make me static (consume less memory and CPU resources):
reset(my, DYNAMIC);
// give me a unique value:
my.skill99 = 999;
}
void main(){
// load level etc:
// main game loop:
while(1){
// cycle throw all entities:
for(you = ent_next(NULL); you; you = ent_next(you)){
// if we've found a vegetation:
if(you.skill99 == 999){
// animate it:
animateEnt(you, "frame", 5);
}
}
// wait one frame:
wait(1);
}
}
It's not tested, but should work (at least, it gives you an idea, of how it should work). Greets
|
|
|
Re: Number of functions affect fps?
[Re: 3run]
#421348
04/15/13 21:18
04/15/13 21:18
|
Joined: Sep 2003
Posts: 6,861 Kiel (Germany)
Superku
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
|
To answer your question in the most simple way: Yes, 600+ functions is a little too much as wait(1) is not as fast as one could assume, thus it's wasted resources which could easily be saved in this case. Optimization is important and the fact that your game may run above 50fps on YOUR machine is only a valid reason to not optimize your game when you have the worst (or one of the lowest) computer(s) the game is supposed to run on. However, the question obviously is where and HOW to optimize your game. Setting entities INVISIBLE manually and esp. individually oftentimes only leads to a lower framerate (only try to disable the rendering of big regions, buildings, and the like). You can safely use let's say 100 wait(1) loops (neglecting their content for now), but if you have f.i. 500 little insects or leafs or grass models in your level and should they need an action/ loop, use lists, arrays or something like 3run's approach and thus only one wait(1) loop for all those entities.
"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual Check out my new game: Pogostuck: Rage With Your Friends
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|