Animation – optimization

After a weekend of relaxation I started working on some optimizations for the animation system. First of all, I made an animated version of tetrahedron man that we now use in the game. We can render 30 000 agents, with animations, rotations and positions, and AI at around 12 fps. The low FPS is mainly because of the skinning shader, which currently takes a lot of juice to render, so there are some optimizations to be done there. I managed to cut down the amount of memory fetching by changing from matrices to quaternions when passing the data to the GPU. This didn’t give a¬†measurable¬†performance increase however, but it does look neater with less pixel fetches in the shader. Also, I found that by checking whether a weight is zero or not could eliminate both unnecessary texture fetches, and matrix multiplications, increasing the FPS by quite a bit. I’ve also come up with another optimization technique I could use to speed up the skinning. One of the major problems with the shader is that it does so much per each vertex, but that isn’t necessarily needed. Seeing as the model actually renders the same vertex several times (one vertex can have more than one texture coordinate and normal), the exact same operations will be done on the very same vertex several times. So to fix this, I though of rendering the vertices separately, save their positions to a texture, and then when the actual rendering is active, just fetch each vertex positions from this texture.

I’ve also worked on the distribution system for the animations. One can now queue either one animation, or a combination of several and bind them to an AI, and that particular AI will move using that animation. I will also add a way to force animations to play using a new skeleton, so that one can choose if two persons should move with the exact same time step or not.

//Gustav Sterbrant

Be Sociable, Share!