GPU based key frame interpolation

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

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 on other sites
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 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 on other sites

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 on other sites
Quote:
 Original post by pollux070282Regard 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.

1. 1
2. 2
3. 3
Rutin
15
4. 4
5. 5

• 10
• 9
• 9
• 11
• 11
• Forum Statistics

• Total Topics
633685
• Total Posts
3013317
×