Skip to main content
gamedev.net
🔒 Locked

animation interpolation

Started by kRogue Mar 3, 2004 at 4:17 AM 2 replies 500+ views
Original Post
kRogue
kRogue
I have yet another newbie perfomrnace question/openGL function question: very often in animating a model, one has two frames, and one interpolates between them. i.e. frame1 has say vertexArray1 and frame2 has vertexArray2, so to draw smoothly between them, one does (co-ordinate wise): drawingArray= vertexArray1 + timeInterpole*(vertexArray2-vertexArraz1) where timeInterpole is a float between 0.0f and 1.0f which indicates how far along one is going from frame1 to frame2... does openGL have any routines built into it to do the interpolation for you? since a for-loop compiled would be signifaclty slower than assebly writing the loop yourself... another apporach would be to use BLAS, though I do not know where to download a _fast_ implentation of BLAS (the above should be BLAS level 1 or 2) any pointers on a place to get a good BLAS (for linux) or of an openGL call would be much appreciated. (BLAS=Basic Linear Algebra Subroutines)
Close this Gamedev account, I have outgrown Gamedev.
JTippetts
JTippetts
You could write a vertex program to perform the vertex blending. You pass both sets of vertex coords and a weighting factor to the program, and the shader performs the calculation on the GPU. For cards with good shader support (read: Geforce3 and above), this would be a lot faster than performing the interpolation on the CPU.

The ARB_vertex_program extension spec contains this little snippet for just this case:

(71) How do you perform a vector weighting of two vectors using a single weight?

RESOLVED: As follows.

# result = a * vec0 + (1-a) * vec1
# = vec1 + a * (vec0 - vec1)
SUB result, vec0, vec1;
MAD result, a, result, vec1;

where a holds the passed interpolation value, whether it is passed as a vertex attribute or a local parameter. Total of 2 simple instructions performed on the GPU. Then, when you draw the mesh, all you need to do is acquire vertex array pointers (if that is how you draw) to both frames, and pass the vertex data for both keyframes along with timeInterpole, and the shader does the rest.


Golem
Blender--The Gimp--Python--Lua--SDL
Nethack--Crawl--ADOM--Angband--Dungeondweller
kRogue
kRogue
that would be sweet, except I am using a GeForce2 to learn this stuff ;( it is exactly what I would need.... ergg... so bothering.. old Gfx card... oh well when I get back home I''ll get a nice new shiny one (but it will be another 4 months before then!) and to add insult to injury my motherboard is so anicient (i.e. AMD irongate) it has nothing beyond AGP2X and the newer cards want AGP4X or usually AGP8X (actually the Irongate is worse, it really can only do AGP1X reliably) getting a new machine.. hi ho, off my money goes!
Close this Gamedev account, I have outgrown Gamedev.
JTippetts
JTippetts
If all you are doing is experimenting, vertex programs may work with GeForce2 just fine. You just don''t get the performance. On my card, I get worse frames per second using shaders than by performing the calculations on the CPU for just about every animation task. But it''s fine for getting the theory down, at least, as long as you have updated drivers which support it. And as along as you have access at least some of the time to a higher performance machine to see if you are getting the desired increase in performance on higher-end hardware.


Golem
Blender--The Gimp--Python--Lua--SDL
Nethack--Crawl--ADOM--Angband--Dungeondweller

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.