Sign in to follow this  
biraneto

GLSL skeletal animation

Recommended Posts

biraneto    122
Hi all. I am currently willing to start implementing character skeletal animation using glsl shaders. My problem is that I'm having trouble finding good information on how to do this... even here in the forum search (maybe I'm not being able even to figure out the words for finding it :) ). I couldn't find a good tutorial or sample of simple animation using vertex shaders. Anyone has good advice/links/samples/tutorials on this? (using glsl shaders please) Also, are vertex shaders really the best way to implement character skeletal animation? thanks in advance

Share this post


Link to post
Share on other sites
bzroom    647
My suggestion would be to implement skeletal animation on the CPU before you try to do it on the CPU, it's way easier to debug that way, and it's not always the easiest to debug in the first place.

It will require a good understanding of matrix math. Once you have this understanding, and prove it on the CPU, it's very easy to move it to the GPU using shaders. But the math needs to be buffed out first.

If you can find a web archive of: rsn.gamedev.net he had a sweet skeletal animation and milkshape model loading tutorials. It's a fairly straight forward concept once you get your head around it.

Share this post


Link to post
Share on other sites
Einar89    144
I agree with what bzroom said, about first implementing it on the CPU, and porting it to the GPU. The main advantage of using the vertex shader for this is that the vertex shader is rarely a bottleneck.
All you have to do is pass the three(initial, parent and animated) matrices with glVertexAttrib4f. You will basically have 3 calls per matrix. You then do the normal matrix multiplication in the vertex shader.

Share this post


Link to post
Share on other sites
bzroom    647
I usually do all my matrix multiplication for the skeleton on the CPU, and i store my mesh in bone space. That way i can pass only an array of final bone transforms to the vertex shader, with one attribute call, and only multiply the vertices by their final transform.

I dunno if this is the best way to do it. Just stating my difference.

Share this post


Link to post
Share on other sites
dmail    116
Interesting, I also update the skeleton on the CPU. Upload the joint matrices to a uniform array and then send the weights and matrix indices as attributes per vertex to the GPU. Obviously the extra information is for skinned animation.

Share this post


Link to post
Share on other sites
Einar89    144
I feel really stupid, having just realized what I wrote. The way I described it is wrong, because you end up redoing a lot of calculations.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this