leclerc9

How do games like Medieval: Total War 2 render hundreds of skinned models running different animations on the screen and still run at a good frame rate Is it possible that the models are not skinned

I can't get more than 100 skinned models (matrix palette size = 50, verts = 5000) to run without getting a noticeable frame rate hit. This has to do with the fact that I am using shader instancing and doing 100 draw methods. I confirmed this by taking out all the animation and update code and only calling draw 100 times every frame.

It's possible that my shader is inefficient (the DirectX examples split the shaders up based on influences per vertex), but I don't think it would be that huge of a difference. My skinning function is very similar to those in the DirectX sdk:

SKIN_OUTPUT Skin4( const VS_INPUT input)
{
SKIN_OUTPUT output = (SKIN_OUTPUT)0;
float lastWeight = 1.0;
float weight = 0;
for (int i = 0; i < 3; ++i)
{
weight = input.weights[ i ];
lastWeight -= weight;
output.position += mul( input.position, MatrixPalette[input.indices[ i ]]) * weight;
output.normal += mul( input.normal , MatrixPalette[input.indices[ i ]]) * weight;
}
output.position += mul( input.position, MatrixPalette[input.indices[ 3 ]])*lastWeight;
output.normal += mul( input.normal , MatrixPalette[input.indices[ 3 ]])*lastWeight;
return output;
};


The only way I can think to speed up performance is to store the interpolated keyframes in a texture (would have to be huge) and use shader 3.0 hardware instancing to designate the starting pixel location for the matrix palette in the texture. I don't even know if this would work (and I don't know how I would get it to work with dynamic keyframing), and somehow I doubt that this is how modern games solve this problem.

Does anyone have any advice I've been suffering for a while trying to solve this.  Thanks!


Re: XNA Game Studio Express Rendering hundreds of models

Leaf.

You might find the Drawing A Crowd article from the Shader X3 book to be useful.

Cheers,
Leaf.






Re: XNA Game Studio Express Rendering hundreds of models

leclerc9

Thanks, that is an absolutely amazing article, and it references Shawn Hargreaves.

Exactly what I was looking for, and makes you wonder what is possible with shader 4.0...




Re: XNA Game Studio Express Rendering hundreds of models

leclerc9

Oh, and if you don't mind me asking, do you have that book by chance (or does anyone here) That article makes me want to buy it, but since it's the only article they list from the book, the quality of the other articles may be worse. I have the shader X2 book, and in my opinion, it is very mediocre.




Re: XNA Game Studio Express Rendering hundreds of models

Leaf.

I have the ShaderX4 book and I've flicked through the X3 volume at work. I think they are useful references to have around. The articles can be a bit hit and miss but that can be a problem with any of these books that have many authors (Game Programming Gems is similar, though I have all of them and only one of the ShaderX books).

Check out the contents and see if some of the other articles are interesting to you. Also have a look around the web as many of the authors eventually put the articles up on the web.

Cheers,
Leaf.