Jump to content
  • Advertisement
Sign in to follow this  
zacaj

Skeletal Animation and GLSL

This topic is 3479 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

What is the best way to perform skeletal animation when using GLSL shaders? Ive had a few ideas: 1. Perform quaternion/matrix concatenation on CPU, and somehow send concatenated matrices/quaternions/matrices from concatenated quaternions to GPU, and then transform points by matrices/transform points by quaternions/convert quaternion to matrix and transform points 2. perform quaternion/matrix concatenation on CPU, and then transform points on CPU and send transformed points to be drawn normally 3. Send un-concatenated quaternions/matrices to GPU and let GPU concatenate them and transform points Theres problems with each method though: method 1: 1. sending matrices/quaternions to GPU(quaternions could be passed as extra vertices or attributes, but it seems like a lot of information to be sending matrices 2. if you send quaternions, you would have to transform each point by quaternion, which is slower than transforming by matrix, or would have to make a matrix out of each quaternion on the GPU and transform it, which would be slower unless you could save matrices for future vertices method 2: 1. This doesnt seem to be a good way to do it at all. method 3: 1. Id need to be able to store concatenated matrices to have any hope of good speed So, my questions are: 1. is concatenating and transforming on CPU fastest way to do this? 2. Is it possible to store results of calculations(matrices) between each execution of the vertex shader 3. would it be possible to make a seperate shader that would concatenate matrices or quaternions, and then save them on the GPU for the actual model's vertex shader to use later? 4. What is the standard technique of performing skeletal animation?

Share this post


Link to post
Share on other sites
Advertisement
From most cases i've seen, the common way is similar to your first solution. That is, you recalculate all your bone transforms on the cpu, and pass them to your vertex shader via a uniform array of matrices.

Also, you can't store the results of calculations between executions of the vertex shader because they are run in parallel of each other.

Share this post


Link to post
Share on other sites
-Each vertex has weights for each bone matrix.
-Each bone matrix is the full concatenated matrix of itself + all parent bones.

Send the weights per vertex and the concatenated matrices. Then in a shader just multiply each vertex by the correct matrices and weights.

Since your storing a matrix for each frame, for all bones, you can just do the concatenated matrix for each frame once at run time.

To make a simple test, instead of weights, you can send a matrix index, and just transform a vertex by 1 matrix.

Share this post


Link to post
Share on other sites
To make things clearer, only the final transforms should be stored in the array of matrices (no need to muck around with Quaternions in your shader). In your vertex shader, you then access this array using indices passed in as vertex attributes. You can also use blend weights if more than 1 index is used. Just google "skinned vertex shader" and you should find lots of tutorials on this common technique.

Share this post


Link to post
Share on other sites
Currently im just trying to get basic animation(no vertex weights yet), so basically, I should concatenate the matrices/quaternions on the CPU, and send bone indexes and matrices/quaternions converted to matrices to the GPU for final transformation...
Should I use quaternions on the CPU and convert to a matrix to send to GPU, interpolate matrices, or interpolate rotations, make matrices from the rotations, concatenate those together, and send that to the GPU?

Also, is it possible to pre-concatenate the quaternions/matrices when you save the 3d model, so you have a fully concatenated matrix/quaternion that you can just interpolate and send to the GPU?

Share this post


Link to post
Share on other sites
Quote:
Original post by zacaj
3. would it be possible to make a seperate shader that would concatenate matrices or quaternions, and then save them on the GPU for the actual model's vertex shader to use later?


If you are doing a huge number of them, then yes you can try transform_feedback extension at http://www.opengl.org/registry

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!