Hardware Instancing and Animations

There are some samples here on the fora showing hardware instancing.
There are some samples here on the fora showing hardware skinning (animation).

Now there is a sample showing both, usable in a real life scenario where you’d want to play a different animation on each instanced actor.

In most cases this solution should be faster then doing the same on the CPU. In my own test I can get 50 actors (with 24k verts each) running at ~65fps with frame blending and ~90fps without frame blending. Using Panda3D Actors for the same scene I can get 300fps when the animations are nor running and 4.5-10 fps when the Actors are animated. People on IRC reported it running even at 650fps, so mileage may vary.

Unfortunately you need some (automated)pre-processing to get a model to work with this system.

The code and sample is available here:

If you have questions - ask here or on IRC (or Github if you have to).


1 Like

Impressive! Nice work. This will be very useful for crowd/army simulation.

Of course all this would not happen without the help from rdb. Sorry for not writing that, but I’d be surprised if anyone here has any project that rdb didn’t help with.

Anyway, I just pushed an update, now you can attach a node to a joint, just like you could with the Panda3D Actor, the function for that is on the Crowd, not CrowdActor:

self.crowd.attach_node_to_joint(node=hat, joint_name='head', actor_id=11)  
#no :(
#self.crowd[11].attach_node_to_joint(node=hat, joint_name='head')  

I did it this way because I didn’t want to create cyclic references where the Crowd keeps a pointer to each CrowdActor and each CrowdActor has a pointer to the Crowd and also because on the scene graph the attached node gets parented to Crowd.model not the dummy nodes of CrowdActors.

Behind the scenes attaching works by using the joint matrix as (part of) the model matrix in the shader, so if you attach something to the something attached to a joint - it won’t work. Also I had to set omni bounds on the attached object, so no culling.