Performance tips

Started by
30 comments, last by Hassanbasil 12 years, 8 months ago
Hello everybody

I'm working on an engine for a game i'm planning to write, i plan to make it an RPG, and if it goes well, i might evolve it to be an MMORPG, where the player is a part of an army.
i've done alot of stuff - but performance is killing me, as it's an army, there should be a massive number of soldiers, terrain, and some trees/rocks, well at least in the battlefield, terrains are not much of a problem, LOD will solve the problem, as not much of it will be visible anyway, so the main problem is the soldiers, it looks like a low poly soldier will be composed of at least 500 vertices to look half-decent, which could be satisfying, but that seems to be too much to render, let's say there are a thousand visible soldiers, i tried rendering them with a basic flat color effect, and the FPS was 4.

so yeah, that's the problem - i can reduce the visible amount of soldiers by adding alot of fog and dust (caused by war chaos), it gives some realism too, anyway, but i will still need to render some hundreds of soldiers - what can i do to improve performance? will multi-threading be of good use here? how?

please feel free to share thoughts, ideas and tips
Advertisement
Hello

Do you use (plan to use) geometry instancing for rendering your soldiers ?
I would think this is necessary here because you plan to render a lots of time the same geometry
If it helps, and i can use it, why not!, but i have read somewhere that the maximum amount vertices for instancing is 32, i don't really know if thats true, and i really hope it's not, i might have misread it perhaps? well, what are the restrictions of instancing? does every instance have it's own animation frame?
i yet haven't applied animation system (which is next on my list), so i'm not yet sure about it.

thanks for the suggestion - i hope instancing large objects is possible.(large in vertex count)
They're no such limitation as far as I know (I'm using it with 100 and more instances, at least)
(Maybe this is more a problem of cache; if the geometry can't be held as a whole in the cache, there will be cache swapping, and this could lead to performance fall.)
You can handle animations (skin meshes) with instancing

:rolleyes:
thanks for the reply, i will implement instancing now and see how it goes - as for multithreading, does anyone know if it could benefit me? a feature of Direct3D11 is multithreaded rendering, but does it improve performance? i have seen users reporting weaker performance with it, is that true?<br>
What version of D3D are you using?

Assuming D3D9, how many calls to DrawPrimitive or DrawIndexedPrimitive are you making? You need to reduce the number of draw calls as much as possible if you want to get good performance - which is what instancing helps with.
I'm using D3D11, sorry for not mentioning this.
I've got a question regarding instancing: how are instances rendered without an index buffer? how are triangles connected to each others?


EDIT: figured out that DrawIndexedInstanced exists, well it's pretty nice, and FPS is increased by a great amount, though, still not enough, what else can i do? i'll ask once again, is multithreading able to help me, or it's a waste of time?
-Reduce all unnecessary state changes.
-Use Instancing as much as you can (there's a sample in NVidia DirectX 10 SDK called "Skinned instancing" take a look at it; You should be able to draw all soldiers with a single draw call
-Profile - Get nVidia PerfHUD or AMD PerfStudio and find out if you're either CPU or GPU bound (if you're GPU bound check what is doing most of work, vertex or pixel shader, and also if your ALU or Texture-fetch bound.
-Try to get decent frame rate without using multi-threading...

What technique are you using to render terrain? Does you use any LOD terrain technique? Again, PerfHUD can show you if your using too much time in terrain rendering or something else...

Use the data you get from profiling programs to see what you have to improve.

I'm guessing you are either doing too much work on the vertex shader rendering the soldiers and the terrain. Have you considered using billboards to draw distant soldiers? (4 vertices per soldier = WIN) :wink:

EDIT: Some time ago I read a paper about rendering thousands of zombies onscreen... (It was from Valve or something, I can't find it now but maybe someone knows :rolleyes: and I think it might be useful to you)
I will look into PrefHUD now.

Actually i'm running a simple test to have my proof of concept, yet, the test only renders a quad of 2 triangles and an amount of soldiers, all soldiers are rendered in 1 draw call, will not use my terrain currently as it has very poor LOD system and thus not very efficient, might look into tessellation for a solution, because LOD is already causing me alot of problems

as for state changes - i think they're not alot, but do they really consume much time?

also, well, im using a little bit heavy shaders, running with flat color shaders gives me 300-400 FPS in 640x480 windowed, but that is not quite satisfying, as i will need texturing, and i really want to have per-pixel lighting for some planned effects - which will probably drop me below 60 FPS, even in 640x480, but i will try to tear it apart and might even end up with vertex lighting if it's faster

though, the soldiers will not be of the same type, there will be at least 4 types of soldiers, plus up to 4 unique characters, with rocks and trees, i will need more draw calls, thus less fps, so i thought maybe i could make 2 threads, each one renders a part, and when they both finish, i present the swap chain - wouldn't that speed things up?

EDIT: @ your edit: billboards are great - i will look into them, but, aren't they for static objects? if each soldier has his own animation, wouldn't i need to render each soldier to rexture and then render it on a quad? this seems slower than usual :P, though, i will (eh, must..) use billboards for trees/rocks

This topic is closed to new replies.

Advertisement