Jump to content
  • Advertisement
Sign in to follow this  
pollux070282

GPU based key frame interpolation

This topic is 3158 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

Hello community! I have a theoretical question about GPUs (with which I unfortunately am not very familiar). I know that vertex programs work on a per-vertex basis. So, if I want to animate a model using keyframing, is there a way to let the GPU handle the interpolation process? My problem is that I am not sure how to hand both keyframes to the GPU at the same time. As far as i understand the whole process, I render the model in keypose A and could interpolate every vertex with its destination in another keypose B. So for me the question is, how do I get the target positions into the shader? Best regards, Mike.

Share this post


Link to post
Share on other sites
Advertisement
You bind two streams of vertex shader inputs, one is the vertices, normals etc. of the first keyframe, and the same for the second. Then you pass the current tween factor in as a uniform float, and write your vertex shader to interpolate between the two streams before transforming the result.

Share this post


Link to post
Share on other sites
You need a vertex format that looks something like this

struct MyVertex
{
float x1, y1, z1; //Vertex
float x2, y2, z2; //The next keyframe's vertex
float nx1, ny1, nz1; //Normal
float nx2, ny2, nz2; //The next keyframe's normal
float s, t; //Texcoord
};

and you need to prepare your VBO accordinly.
In the vertex shader, you will thus have the vertices from 2 keyframes.
Then you pass some tween factor as a uniform float. The tween factor would be a value from 0.0 to 1.0. You also need some code that decides what part of the VBO needs to be uploaded since when you reach 1.0, then it is time to bind the next keyframe and use tween factor 0.0

Share this post


Link to post
Share on other sites
First of all, thanks for your comments.

Unfortunately, I still have a few questions. As for the first proposed method, this is exactly what I have in mind. Can you point me towards what to google for (since my searches are still relatively fruiteless)?

Regard V-Man's answer: This kind of looks like a lot of overhead. If I wanted to tween between arbitrary keyframes, doesn't that mean I have to keep track of a quadratic number of keyframes?

- Mike.

Share this post


Link to post
Share on other sites
Quote:
Original post by pollux070282
Regard V-Man's answer: This kind of looks like a lot of overhead. If I wanted to tween between arbitrary keyframes, doesn't that mean I have to keep track of a quadratic number of keyframes?


Yes, keyframes consume a lot of space compared to skeletal animation.
If you want to tween between arbitrary keyframes, then perhaps interleaving is not a good idea.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!