I guess this is what I get from writing something just before going to sleep. I know that the 900 animated models, which after waking up I am using 25*25 = 625 animated models, which consists of 4 different characters, and 1 of the 4 characters has 2 models (body and clothes). So the amount of models would then be 625 * 5 / 4 ? 780.
The 780 models is probably 20 times more than I would ever need to use, and on my phone it runs perfectly fine 60 fps even with over 100 animated models (roughly 1000 faces, 20 bones per model). This is actually more than enough in terms of performance, but I am not expecting every phone to be as fast as my nexus 5.
This is on desktop:
Why I was asking about lod for skeletons is because at least on my test, if you have animated model with 20 bones and opengl3 or my phone which uses opengl2es, regardless if I animate it or not, there is almost no performance difference. This probably also means that I become gpu bound. On opengl2, the urho there seems to be lot less gained between having a model static vs animated. I noticed that I became cpu bound, and it was running roughly 100 fps, 72% gpu usage and with static models 168fps, 100% gpu usage. So if I count 168 * 0.72 ? 120 fps, which would be like 20% increase, which might not mean much as a number, considering its also freeing cpu usage. On a side note, things generally did run a lot faster on my setup using opengl2 than 3, but I suppose opengl3 leaves more cpu power to do other things.
On another side note, I am guessing that for current phones (android at least?), I can assume that phones when rendering 3D will almost always be more likely to be GPU bound than CPU bound. Considering a lot of em are quad core 2+ghz CPUs, and the GPU is probably a lot less powerful than CPUs. Although I have no idea what kind of performance
With example on desktop same scene, same models one where I have same model as static mesh and other as a animated mesh. Without instancing there was still almost 200% fps gain when changing the animated models to static ones. What I noticed is that with high amount of models animated models, I started to become cpu bound. I have honestly never seen so high usage of cpu in any game as I’ve seen on Urho (something to notice though I am not exactly running a game, just graphics rendering currently), although I haven’t used linux more than a month, so maybe it is a linux vs windows thing as well (on 6 core system 50% cpu usage). I gained 50% fps when I stopped animating the models, but what I did notice is that when I was animtaing the models, my gpu usage was 66%, and when I stopped animating them, it went to 100%. This would pretty much explain the 50% gain, to become gpu bound. So I guess with opengl3 the gpu usage is same or pretty close to same regardless if the animation is running or not, but cpu usage is a lot lower.
This made me think, although I havent tested, how would a character with different skeletons work. Like if I had one version where whole arm = 1 bone, leg = 1 bone, so arms + legs = 4 bones and then spine and head, so there would be like 6 control bones + root bone. Surely you cannot control the character so well with less bones, but I would assume it would free up some gpu.
The project that I hopefully will eventually get on to would be tactical rpg or something. There seems to be one similar one http://discourse.urho3d.io/t/my-project-wip/818/1. Basically doing something similar as Setzers. From his video you can see that the other character stands still, which I figured in my case could be static mesh, then when selecting the unit, it would swap into animated one to save some frames with phone.
Also I do think that I might be going too much of trying to optimize things that aren’t exactly neccessary. Then again I am very noobish and have almost 0 knowledge about 3d, so its been kind of testing stuff for the past few months. This means that I might be looking at completely wrong kind of things to begin with. When I first thought about 3D on mobile phones, I thought I could just dump just about anything on the screen and phones would today be fast enough to handle it, but I guess I have proved myself that it is very wrong to assume such.
Edit forgot to put the code for the creating of animated node. It is using pretty much sample 06 with just compounding several different models on one node.
Urho3D::Node* MainGame::addAnimatedModel( Urho3D::Node* node, Urho3D::String nodeName, Urho3D::String folder,
Urho3D::String modelName, Urho3D::String matName, Urho3D::String animName, bool createOutline ) {
Urho3D::ResourceCache* cache = GetSubsystem<ResourceCache>();
if( folder.Length() > 0 )
folder += "/";
modelName = folder + modelName;
matName = folder + matName;
animName = folder + animName;
Urho3D::Node* modelNode = node->CreateChild( "GameUnit_Node_" + nodeName);
Urho3D::Node* modelDynamicNode = modelNode->CreateChild( "GameUnit_Dynamic_" + nodeName);
Urho3D::Node* modelStaticNode = modelNode->CreateChild( "GameUnit_Static_" + nodeName);
createAnimatedModel( modelDynamicNode, modelName, matName, animName );
createStaticdModel( modelStaticNode, modelName, matName );
// Create outline
if( createOutline )
{
Urho3D::Node* modelStaticOutlineNode = modelStaticNode->CreateChild("GameUnit_Outline");
createAnimatedModel( modelDynamicNode->CreateChild("GameUnit_Outline"), modelName, "Materials/OutlineMat.xml", animName );
createStaticdModel( modelStaticOutlineNode, modelName, "Materials/OutlineMat.xml" );
modelStaticOutlineNode->SetEnabled(false);
}
modelStaticNode->SetEnabled(false);
return modelNode;
}
void MainGame::createStaticdModel( Urho3D::Node* node,
Urho3D::String modelName, Urho3D::String matName )
{
Urho3D::ResourceCache* cache = GetSubsystem<ResourceCache>();
Urho3D::StaticModel* modelObject = node->CreateComponent<Urho3D::StaticModel>();
modelObject->SetModel(cache->GetResource<Urho3D::Model>(modelName));
modelObject->SetMaterial(cache->GetResource<Urho3D::Material>(matName));
}
void MainGame::createAnimatedModel( Urho3D::Node* node,
Urho3D::String modelName, Urho3D::String matName, Urho3D::String animName )
{
Urho3D::ResourceCache* cache = GetSubsystem<ResourceCache>();
Urho3D::AnimatedModel* modelObject = node->CreateComponent<Urho3D::AnimatedModel>();
modelObject->SetModel( cache->GetResource<Urho3D::Model>( modelName ) );
modelObject->SetMaterial( cache->GetResource<Urho3D::Material>( matName) );
Animation* animation = cache->GetResource<Urho3D::Animation>( animName );
/*
if (animation) {
Urho3D::AnimationState* state = modelObject->AddAnimationState(animation);
// The state would fail to create (return null) if the animation was not found
if (state)
{
// Enable full blending weight and looping
state->SetWeight(1.0f);
state->SetLooped(true);
}
// Create our custom Mover component that will move & animate the model during each frame's update
node->CreateComponent<Mover>();
}
*/
}
void MainGame::enableDisableAnimationsOnNode( Urho3D::Node* node )
{
Urho3D::Node* child;
const Vector<SharedPtr<Node>>& children = node->GetChildren();
for( unsigned int j = 0; j < children.Size(); ++j )
{
child = children[j];
if( child->GetName().Substring(0,14) == "GameUnit_Node_")
{
enableDisableAnimationsOnNode( child );
}
else
{
bool enabled = !child->IsEnabled();
child->SetEnabled( enabled );
if( auto* c2 = child->GetChild("GameUnit_Outline") )
c2->SetEnabled( enabled && bShowOutline_ );
}
}
}
If I uncomment the adding animation thing as in truly add animation to the animated model, the performance gain is there, but it isn’t really that good with opengl3, but if I use static models instead of animated ones, I get almost 200% fps boost, while on both cases gpu utilization is close to 100%.