Engine is slow? Or am I nuts?

Posted By: 3run

Engine is slow? Or am I nuts? - 08/14/11 13:39

Hi there, I'm having a little problem... I've made movement, weather and weapons script for my current project.
I use 3 while loops for all of them, one for weapons, one for weather and last one for all the rest of stuff.
My player's movement uses 2 c_moves, and 2 traces (on for gravity (1000 q) and second for crawling (about 40 q) both with USE_BOX).
I use models for bullets, so each bullet has it's c_move instruction running.
I've set to IGNORE all unneeded stuff for all of "c_" functions, so they won't calculate collusion without need.
I place 5 trees on the level with ground block with default texture, they have no actions but POLYGON flag.
I've set about 10 bush models (they have textures with alpha channel) and they are passable and have no actions.
So, why do I get jerky 20-30 fps when I step into those bushes or when I come close to trees?! WTF?!?!?!

If I remove those models, them I get UNSTABLE 60 fps... By UNSTABLE I mean that it's jerking between 59-60 itself!
WTF am I doing wrong?! My team that works together with me are facing the same problem with fps...
Am I nuts or is GS really slow for a complex FPS? I don't see one around...
Posted By: Quad

Re: Engine is slow? Or am I nuts? - 08/14/11 13:51

first jerking between 59-60 seems pretty damn stable to me. Second, it really all depends on your code. Also if you need polygon level collision, use collision meshes for tree collision, not the tree itself. You also did not mention anything about system specs. so no one can really say anything.
Posted By: Rei_Ayanami

Re: Engine is slow? Or am I nuts? - 08/14/11 14:00

Model for every bullet? Think about: The collision, the draw calls etc.
Posted By: 3run

Re: Engine is slow? Or am I nuts? - 08/14/11 14:54

There is no problems while shooting Rei, weapon system is really fast and optimized enough, I see no problems with it. I get problems with simple trees and grass even without shooting... For trees collusion, I placed invisible box with polygon flag, tree itself is passable. My system is: Windows XP, AMD Athlon 64 3200+ 2.21 GHz, 2.00 GB Ram, NVIDIA GeForce 7600 GS. About 59-60 jecrking fps, Quad you really think that's ok? I see that in my other projects as well... They are way more simpler than the one I've described in first post. As well, what is good fps to play in your opinion?
Posted By: Quad

Re: Engine is slow? Or am I nuts? - 08/14/11 15:18

i had a fully featured FPS with crawling/ladder climbing, ai, shooting, collision, inventory, quests/task, pickup/powerup system and shaders running with 20-30 fps on A6 WDL. It was a indoors horror shooter, kind of like l4d + resident evil 3 on fps. Damn, i had aspiration at the time.

my system was radeon x200m, 1gb ram, centrino processor.

It's either something wrong with your code and/or drivers/system setup.

When something like this happens, think about games like SuperCan, there is alot of enemies and actions with all that pretty shaders, and it works fine. This means problem is on your side not on the engine's. An engine does not slow down with a few trees and bushes in a small level for no reason.
Posted By: 3run

Re: Engine is slow? Or am I nuts? - 08/14/11 15:48

So what could cause that problem? I only have 3 while loops! 20-30 FPS is stable for a game?!
Posted By: Rei_Ayanami

Re: Engine is slow? Or am I nuts? - 08/14/11 15:55

The number of your while loops are not important (I got one main-while loop)..
Posted By: 3run

Re: Engine is slow? Or am I nuts? - 08/14/11 16:02

KK, what is important then?
Posted By: fogman

Re: Engine is slow? Or am I nuts? - 08/14/11 16:03

"So, why do I get jerky 20-30 fps when I step into those bushes or when I come close to trees?! WTF?!?!?!"

-> Fillrate problem!
http://www.conitec.net/beta/framerate.htm

Quote:
The bigger a model or sprite is scaled, and the closer it is to the camera, the slower it is rendered. The rendering time depends on the number of pixels that the object covers on the monitor.


But I donīt know what you could do against it, sorry. frown
Posted By: 3run

Re: Engine is slow? Or am I nuts? - 08/14/11 16:22

Oh, that could be the problem... Thank you fogman, it actually drops down when I crawl in the bushes... And when I'm close to the trees. About you guys telling me that it's something wrong with the script from my side, it works perfect without trees and bushes, so I don't think that this could be the problem, as well, I use only two traces and two c_moves... So I doubt that problem is with script from my side.
Posted By: painkiller

Re: Engine is slow? Or am I nuts? - 08/14/11 17:35

Try to use the F11 stats to find what is slowing down your game
Posted By: Joey

Re: Engine is slow? Or am I nuts? - 08/14/11 18:32

thanks painkiller, I just thought "why does noone say: press F11"?
Posted By: Rei_Ayanami

Re: Engine is slow? Or am I nuts? - 08/14/11 19:29

Shift+F11 will print the slowest function into your acklog
Posted By: 3run

Re: Engine is slow? Or am I nuts? - 08/14/11 19:58

Thanks, I'll take a look now.
Posted By: 3run

Re: Engine is slow? Or am I nuts? - 08/15/11 07:40

OK, I've made little test with F11... BTW, I forgot to mention that problem isn't constant, so here is example:
Quote:
As you see, I sat in the grass as a bunny ^^

I could recreate problem, but only halfway, cause I got fps drop to 43 from 60...
I've placed some more trees, to recreate 20-30 fps drop, but...

Fps is stable (with that jerking between 59-60...), I have no idea why...
About f11, I don't really see anything special... Only "ref" which is jerking from 11 to 18 (when it's 18 then I got the problem with fps I guess).
Here is the normal "acklog", when I didn't get fps problem:
Quote:
Log of A7 Engine 7.86.6 run at Mon Aug 15 01:28:18 2011
Администратор on Windows NT/2000/XP version 5.1 Build 2600
Options main.c -nx 30 -diag
App: C:\Program Files\GStudio7\acknex.exe in C:\Documents and Settings\Администратор\Рабочий стол\UNNAMED\

MM mixer opened
DSOUND device opened
DI interface opened
Start Window opened
(c) Conitec - Dieburg - San Diego - www.3dgamestudio.com
A7 Engine - Commercial Edition V7.86.6 - Aug 7 2010
Development version
Registered to: DMITRY MIKHAYLOV

Mouse found
Realtek AC97 Audio opened
NVIDIA GeForce 7600 GS pure T&L device 1ff9 detected
D3D device NVIDIA GeForce 7600 GS 1ff9 selected.
acknet.dll opened
ackwii.dll opened
t7.dll opened
Compiling MAIN.C - [Esc] to abort........
PATH bmaps\
PATH bmaps\fx\
PATH bmaps\fx\blood\
PATH bmaps\fx\blood\screen\
PATH bmaps\hud\
PATH models\
PATH models\player\
PATH models\props\
PATH models\weapons\
PATH models\weapons\glock\
PATH models\weapons\mp5\
PATH models\weapons\sporting12\
PATH models\weapons\g3\
PATH scripts\
PATH scripts\fx\
PATH sounds\
PATH sounds\player\
PATH sounds\player\footsteps\
PATH sounds\weapons\
PATH sounds\weapons\fx\
PATH sounds\weapons\glock\
PATH sounds\weapons\mp5\
PATH sounds\weapons\sporting12\
PATH sounds\weapons\g3\
PATH sounds\weather\.......................................... 2.601 sec
Running MAIN.C.
25 objects
Main started at 3.750
D3D_Init Window: 800x600 -> Window: 1x800x600x32
Video memory found: 746 MB
LevelInit at 3.812
97 entities 0 cameras 0 lights 0 sounds 0 paths
3 lmaps 5 textures 22 meshes 872 faces...ok
LevelReady at 5.082
def_startup started
fps_startup started
Main loop at 5.086....
1st frame with 746 MB. at 5.323
Nexus overflow at 31446984
D3D_Resize Screen: 800x600 -> Screen: 2x800x600x32
HEADRELATIVE sound: 1
D3D_Resize Screen: 1024x768 -> Screen: 2x1024x768x32
Status at time 102.786 frame 5276 ---------
bbox_mdl_019:thunder_strike V_GLOCK.MDL:v_glock bbox_mdl_019:hero
Maximum Time:
bbox_mdl_019:hero => 0.521686
--------------------------------------
Status at time 104.575 frame 5372 ---------
bbox_mdl_019:thunder_strike V_GLOCK.MDL:v_glock def_debug
bbox_mdl_019:hero
Maximum Time: def_debug => 0.009488
--------------------------------------
Normal exit at 56.158
Close level,DLL,objects
Free input,funcs,panels,defs,syns,views,strings,vars..ok
Free sounds,bmaps,fonts,hash,defs1,script..ok
Close dx,multimedia,D3D,engine,physics,nexus..ok
A7 Engine - Commercial Edition V7.86.6 - Aug 7 2010

(c) Conitec - Dieburg - San Diego - www.3dgamestudio.com
Registered to: DMITRY MIKHAYLOV
Unfreed: 1283, BM1, 69892 bytes
Unfreed: 1535, BM1, 69892 bytes
Close window at 56.279

Posted By: Slin

Re: Engine is slow? Or am I nuts? - 08/15/11 08:34

It is your graphicscard, which isnīt able to handle all the alphablending.
Posted By: 3run

Re: Engine is slow? Or am I nuts? - 08/15/11 08:45

94 entities and 48 of them are visible... are u kidding me? What PC should I have to play thing without any problems? Second screen, 98 entities and 85 of them are visible... 60 fps, WTF? Plus, I'm not the only one who is getting problems with this. My team member are facing it as well, but I don't know what pc they use.
Posted By: Slin

Re: Engine is slow? Or am I nuts? - 08/15/11 09:06

Read what I wrote.
And also read what fogman wrote...
Posted By: 3run

Re: Engine is slow? Or am I nuts? - 08/15/11 09:10

kk, thank u. But I want to know, is this a problem from my side?

Tested on my second PC, same on it as well... with it's NVIDIA GeForce GT 430...
Posted By: Harry Potter

Re: Engine is slow? Or am I nuts? - 08/15/11 10:55

Do you use mipmaps on your grass sprites?
And how many pixels do the grass sprites have?
Posted By: 3run

Re: Engine is slow? Or am I nuts? - 08/15/11 11:16

I really have no idea, I know that mipmaps will increase the framerate, but I don't know how to make and use them.
Here are models info:
Tree:

Grass:

BTW, I didn't use sprites for grass.
Posted By: xxxxxxx

Re: Engine is slow? Or am I nuts? - 08/15/11 11:34

I don't know but when i used the USE_BOX flag, my game was slow. Maybe that is the problem.
xxxxxxx
Posted By: Harry Potter

Re: Engine is slow? Or am I nuts? - 08/15/11 11:37

Originally Posted By: 3run
I know that mipmaps will increase the framerate, but I don't know how to make and use them.
??? cry

a) for models in MED: Skin Settings -> Texture format -> Flag 'Mipmaps'.
b) or use DDS skin with included mipmaps.
c) or at runtime: bmap_to_mipmap(bmap_for_entity(my,0));
d) for sprites: mip_sprites = 1;

Also see 'd3d_mipmapping', 'mip_levels', 'mip_flat' and 'mip_shaded' in the manual.
Posted By: 3run

Re: Engine is slow? Or am I nuts? - 08/15/11 11:49

Thank you, Harry Potter, this will be definitely useful to increase the framerate.
xxxxxxx, yes USE_BOX is slow, but there is no way for me to make smooth movement without it.

Still, problem exist smirk
Posted By: Slin

Re: Engine is slow? Or am I nuts? - 08/15/11 11:54

Again, it is the alphablending. Your grass has an alphachannel and it does not write into the depthbuffer, which means that every pixel is rendered for every grass plane every frame. And those are blended together, which means that the previous colour has to be read and mixed with the new one for every grass plane. This causes your bad framerate if many pixels are covered by your grass. This is a general problem, which will be the same with any engine. You can improve the performance with alphatesting for the completely translucent parts, but I doubt that it will help that much. The only real solution will be not to use transparency and instead do alphatesting and depthwriting or less grass.
Posted By: rayp

Re: Engine is slow? Or am I nuts? - 08/15/11 11:59

In EVERY of my projects since a4 i never managed to have a good framerate (>30). Sure in minigames, top down shooters and whatever it was ok. But i never managed to make a simple 3d shooter with a big map and some ais with a good framerate. With good framerate i mean over 30. Yes i know, u will say its my fault. But i hear a lot of people spoke about the same prob.

Edit: I think this engine just isnt good for 3d ego shooters. Ok, games like left4dead even run with about 30fps. But they have a gigantic map, lot of shaders, lot of pp shaders and hunderts of attacking enemys plus 3 friend-ais around u. u cant compare that.
Posted By: WretchedSid

Re: Engine is slow? Or am I nuts? - 08/15/11 12:04

Although I never made a shooter, I did make a merchant simulation back in 2008. It ran great, had multiple towns with dynamic buildings, vegetation and a AI. It ran smooth on my 100€ hardware (ATI HD2400pro, AMD Athlon 64 2Ghz, 1 Gb RAM). And with smooth I mean 40-50 FPS.

So yeah, it is possible to have good framerate, its certainly not easy, but possible.
Posted By: rayp

Re: Engine is slow? Or am I nuts? - 08/15/11 12:05

Making a today styled 3d ego shooter with pp effects shaders and hell knows in 3dgs = simple not possible, my opinion.
Posted By: 3run

Re: Engine is slow? Or am I nuts? - 08/15/11 12:10

Some guys could tell take a look at Supercan... I wont cause Supecan is a professional game, I'm not a professional...
Plus it's written in LUA, I don't know it.. it's may be faster than lite-c, I don't even know.
Posted By: WretchedSid

Re: Engine is slow? Or am I nuts? - 08/15/11 12:13

Originally Posted By: rayp
Edit: I think this engine just isnt good for 3d ego shooters. Ok, games like left4dead even run with about 30fps. But they have a gigantic map, lot of shaders, lot of pp shaders and hunderts of attacking enemys plus 3 friend-ais around u. u cant compare that.

They (Valve) had also to think about performance. You just can't have a big map the whole time in memory and let it render every frame, you have to stream the map. Having thousand of functions running every frame with their own stack is also a no go for performance.

The straightforward way of just pushing everything in the level and then blaming the engine if it fails might look easy and like a way worth going, but reality is that you have to think too. Sorry if this destroys your view of the world now.
Posted By: 3run

Re: Engine is slow? Or am I nuts? - 08/15/11 12:17

Originally Posted By: JustSid
They (Valve) had also to think about performance. You just can't have a big map the whole time in memory and let it render every frame, you have to stream the map. Having thousand of functions running every frame with their own stack is also a no go for performance.

The straightforward way of just pushing everything in the level and then blaming the engine if it fails might look easy and like a way worth going, but reality is that you have to think too. Sorry if this destroys your view of the world now.
First of all, I'm not professional such as Valve guys... Should that mean that there is no way for me to make cool and fast FPS game?
I've made really fast movement and weapons (did everything I could do to make it fast!), but placed grass models and 20-40 fps?!

Posted By: WretchedSid

Re: Engine is slow? Or am I nuts? - 08/15/11 12:28

Originally Posted By: 3run

Plus it's written in LUA, I don't know it.. it's may be faster than lite-c, I don't even know.

LUA is interpreted and thus by definition slower than Lite-C. Given a good compiler, C is one of the fastest languages available. Here is a nice comparison:
http://shootout.alioth.debian.org/u32/wh...&calc=chart
(I'm not saying that the Lite-C compiler produces equal fast output as GCC, plus I'm also pretty sure that Clang-LLVM can produce even faster code).


Originally Posted By: 3run
First of all, I'm not professional such as Valve guys... Should that mean that there is no way for me to make cool and fast FPS game?
I've made really fast movement and weapons (did everything I could do to make it fast!), but placed grass models and 20-40 fps?!

No, I'm not saying that you can't do it. I just wanted to point out that everyone has to put some thoughts into performance.
Plus, your problem was already pointed out by Nils, the problem is the heavy alphablending. A task which isn't done by the engine but by your graphic card so blame it if you want to blame something wink
Posted By: rayp

Re: Engine is slow? Or am I nuts? - 08/15/11 12:28

I have never seen a good looking big 3d shooter running fast with this engine, nor done by myself or any other person around in this forum. Show me, then i believe.
Posted By: 3run

Re: Engine is slow? Or am I nuts? - 08/15/11 12:33

Originally Posted By: JustSid
A task which isn't done by the engine but by your graphic card so blame it if you want to blame something wink
I've already said that I've tested compiled version of my project with my other PC, and it has NVIDIA GeForce GT 430.
I've played a lot of great games with high settings on it, games which require tough PC, and I'm getting 20-40 fps with 80 bushes? grin
Posted By: WretchedSid

Re: Engine is slow? Or am I nuts? - 08/15/11 12:34

Originally Posted By: rayp
Show me, then i believe.

Afair it was you who accused A8 to be slow so actually its your task to prove it wink
Beside that, why should I put time and effort in something that doesn't even remotely interest me? Like I said, its not easy but its doable.
Posted By: Slin

Re: Engine is slow? Or am I nuts? - 08/15/11 13:01

Making good games needs a lot of time, knowledge and experience. If you lack one of those things, you wonīt be able to create good/complex/big games. There are endless tricks to make things fast and if you start with doing the worst thing possible performance wise, which is alphablending with lots of pixels, you do something wrong.

About the 6 Zombie example, what shaders do you use, how are the zombies animated, are you using stencil shadows?
99.99% of the shaders around are extremely slow, because they where never really optimized in any way and just thrown together by beginners, as for example me 5 years ago. Bone animations on the CPU are also very slow, because it needs your vertex data on the gpu to be updated every frame, while doing it in a shader is a lot faster, especially in combination with tangents, depending of your models, this can speed things up like 10 times and a best case scenario. Stencil shadows in gamestudio are really slow. Donīt use, or use very lowpoly meshes for them.

Edit: There usually is a reason if things are slow and most of the time, there is a solution, which has nothing to do with the engine.
Posted By: 3run

Re: Engine is slow? Or am I nuts? - 08/15/11 13:12

I did everything I know (what I got from the manual) to make things fast...
Ok, framerate problem is my bad, not only mine but my old outdated graphic cards...
Posted By: rayp

Re: Engine is slow? Or am I nuts? - 08/15/11 13:17

I dont use any kind of shadows cause then is everything over ^^

I used the std. mtl_specBump shader and animated them via ent_animate (bones). The model itself had +-4.000polys. 512x512 dds texture.thats it.

But i dont want to talk much about it, i just wanted to say i have fps probs too (nearly always).
Posted By: Slin

Re: Engine is slow? Or am I nuts? - 08/15/11 13:22

Quote:
I used the std. mtl_specBump shader and animated them via ent_animate (bones). The model itself had +-4.000polys.

That shader needs tangents, if you would do the animations in a shader it could very well be a LOT faster.
Posted By: rayp

Re: Engine is slow? Or am I nuts? - 08/15/11 13:32

How can i do that ? As u know iam a shader noob. U have an example of that ?
Posted By: Joey

Re: Engine is slow? Or am I nuts? - 08/15/11 13:35

alpha blending istn't that slow. on my old gf 440 mx i got around 30 fps for an approximate 10x full-screen overdraw with additive alpha blending.
Posted By: 3run

Re: Engine is slow? Or am I nuts? - 08/15/11 13:41

So, isn't that the problem causing low framerate for me?
Posted By: Harry Potter

Re: Engine is slow? Or am I nuts? - 08/15/11 14:41

Originally Posted By: Joey
alpha blending istn't that slow.
I agree.

In my project (Pax et Bellum) I use thousands of grass models with alpha channel.
And I have no problem with the frame rate, because I use mipmaps and LOD.

Originally Posted By: Joey
Your grass has an alphachannel and it does not write into the depthbuffer, which means that every pixel is rendered for every grass plane every frame. And those are blended together, which means that the previous colour has to be read and mixed with the new one for every grass plane.
That's right.
But if you use mipmaps, only the smaller mipmap must be rendered when an object is far away. Rendering/blending is much faster then.
In my game I use very detailed textures (8192 x 8192 pixels). To render them as fast as possible, I use DDS textures with 9(!) Mipmaps.

Here you can see a screenshot of my game with thousands of grass models (all with alpha channel). The frame rate is higher than 60 FPS even though the level is not finished and optimized now (the grass models in this test level are old models with only 4 Mipmaps, and I use no LOD).


(click here to see the original size of the screenshot)
Posted By: 3run

Re: Engine is slow? Or am I nuts? - 08/15/11 14:49

Screens are great, you've done great job Harry Potter. May be I'll need to rewrite my project, so that way I could make it better or something...
Posted By: Rei_Ayanami

Re: Engine is slow? Or am I nuts? - 08/15/11 14:53

When I am not wrong, than you misunderstood him.

The things he discribed are no scripts but changes on the sprites (LOD/MipMap)
Posted By: Slin

Re: Engine is slow? Or am I nuts? - 08/15/11 14:53

Harry Potter: How do you handle sorting?
Posted By: 3run

Re: Engine is slow? Or am I nuts? - 08/15/11 14:57

Rei_Ayanami, I've already done MipMaps with help of Harry Potter, I meant that may be I need to look more deeper into my problem.
And still, even Slin and others say that problem is with alpha thing, I don't believe that my PC can't draw 80 bushes!
Posted By: Slin

Re: Engine is slow? Or am I nuts? - 08/15/11 15:05

As a quick test try this effect on your alpha stuff: http://www.opserver.de/wiki/index.php/ImprovedOverlay
Posted By: 3run

Re: Engine is slow? Or am I nuts? - 08/15/11 15:09

Did, what was the point? Same fps, but still as I said earlier, fps problem isn't constant.
Posted By: Harry Potter

Re: Engine is slow? Or am I nuts? - 08/15/11 15:12

Originally Posted By: Rei_Ayanami
When I am not wrong, than you misunderstood him.
The things he discribed are no scripts but changes on the sprites (LOD/MipMap)
Yes.
When I do not use mipmapping, my game would run with less then 5 FPS. Because all my detailed textures will be rendered each frame. When using a texture size of 4096x4096 pixel (eg. a flat sqare model with a texture), the engine must draw 16777216 Pixels each frame for only ONE model.

So I use mipmaps to reduce the texture size of models that are far away. It's the same like LOD, but for textures.

For example: when you use a texture size of 4096x4096 pixel, then I use 8 Mipmaps for them.
The original texture has 4096x4096 pixels,
the 1st mipmap only 2048x2048 pixels,
the 2nd mipmap only 1024x1024 pixels,
the 3rd mipmap only 512x512 pixels,
...
mipmap number 8 will have a texture size of only 16x16 pixels. And this is rendered much faster than the original texture size of 4096x4096.
Posted By: Harry Potter

Re: Engine is slow? Or am I nuts? - 08/15/11 15:25

Originally Posted By: Slin
Harry Potter: How do you handle sorting?
That's my biggest problem. wink

There are two ways to handle them:
1.) The polygons within a model are sorted by their internal number (time of creation). So the first created polygon will be rendered first. For my flower model (see screenshot) I first modelled the lower part of the flower. So this lower part will always be rendered in the background. And the white flower was created last, so it is always rendered in the foreground. So I have no sorting problem.

2.) The model itself is sorted by it's X,Y,Z-Position. You can change the centre of the model to affect the rendering/sorting.

It is much work to prevent wrong sorting. wink
Posted By: Slin

Re: Engine is slow? Or am I nuts? - 08/15/11 15:26

Originally Posted By: 3run
Did, what was the point? Same fps, but still as I said earlier, fps problem isn't constant.

So the performance problem is still there afterwards and your grass looks ugly with it? If so, your problem is not alpha blending, but something else.
Posted By: TechMuc

Re: Engine is slow? Or am I nuts? - 08/15/11 15:31

Can you send me the project to timo (dot) stark (at) dev-software (dot) com?
I can give it a check this evening.

Greetings,
Timo
Posted By: Harry Potter

Re: Engine is slow? Or am I nuts? - 08/15/11 15:31

Originally Posted By: 3run
And still, even Slin and others say that problem is with alpha thing, I don't believe that my PC can't draw 80 bushes!
I have seen that you use bones animation for your grass models?! Can this be the problem (bad coding of animation)?
Posted By: Pappenheimer

Re: Engine is slow? Or am I nuts? - 08/15/11 15:35

3run, what frame rate do you get when you run your project in window mode?
Posted By: 3run

Re: Engine is slow? Or am I nuts? - 08/15/11 15:40

Yes, there are bones, but I don't use them (model isn't animated BTW).
I've converted example from AUM, where grass where reacting for player and moving randomly by faked wind.

Slin@ grass is highlighted (as well as trees), and yes, still from time to time I get low framerate.

Pappenheimer@ it's same jerking from 59-60, when I get in grass sometimes I get this 20-40 fps.

TechMuc@ thank you for offering your help, we'll see may be tomorrow I'll send it to you.
© 2024 lite-C Forums