# motion blending

## Recommended Posts

Where can I find information about motion blending?

Here

ace

##### Share on other sites
I try to use google but I don't find nothing.
I need a tutorial.

##### Share on other sites
This link is very old, but Hugo Elias presents the theory behind stuff pretty well.

Motion Blur

It doesn't talk about how to use recent video cards or any of that stuff, but I started there when I did my motion blur, and I think it was a great starting point.

Good luck!

##### Share on other sites
I don't know motion blur, but I need to motion blending.
I need a algorithm to interpolate between different animations?

##### Share on other sites
Motion blur vs motion blend... I don't really know the difference here. Did you check out the link I gave?

##### Share on other sites
Quote:
 Original post by alessio55555I don't know motion blur, but I need to motion blending.I need a algorithm to interpolate between different animations?

Are you referring to morphing for sprites or meshes?

##### Share on other sites
Quote:
 Original post by alessio55555I don't know motion blur, but I need to motion blending.I need a algorithm to interpolate between different animations?

Are you talking about keyframe animations involving skeletal models?

##### Share on other sites
I have a milkshape 3d model with several animations.It's a skeletal animation.
I would like a smooth transitions between several animations.For example, I want a smooth transition between walk and run.
I don't think that motion blur it's the solution.
Somebody suggest me motion blending, but I don't find a good tutorial.

##### Share on other sites

If your trying to blend between to animations sets its exactly the same as blending between two animation keyframes. You have a start position (or current position if switching animation sets), you have a destination position and X time allocated to get there. So blending from the current positions of the bones to the first keyframe of a different animation is simple.

Ex:

A---B---C---D---E

M---N---O---P---Q

Assume those are two differnt keyframe animations, the top being walk, and the bottom being run.

If you know how to blend between C and D whats different about blending between D and M? or even D.5 (as in halfway between D and E) and M (or P.5 in some cases)? If you have re written your milkshape class and fully understand what it is really doing you should have no trouble adapting it to do what you asked.

##### Share on other sites
I don't know how blend between frames D and M.

##### Share on other sites
check out "keyframed animation" and "linear interpolation" on google... then do following for each vertex:

Vertex[Current] = Lerp(Vertex[Target],CurrentAnimValue);

CurrentAnimValue = a number between 0 and 1, this is where animation is done...

Each update, add a value to CurrentAnimValue.
if CurrentAnimValue > 1, increase the currentframe & nextframe pointers.

The best way of learning is not to copy code from a tutorial or whatnot, but to figure out what needs to be done - and then find ways of doing it.

Cheers.

##### Share on other sites
I know linear interpolation, but it take two point,start point and end point
while in your code I see only one parameter in the function Lerp.

I don't understand what do you tell.
Where is blend operation in your code?

##### Share on other sites
Quote:
 Original post by alessio55555I know linear interpolation, but it take two point,start point and end pointwhile in your code I see only one parameter in the function Lerp.I don't understand what do you tell.Where is blend operation in your code?

You just explained the solution in your own words which is a good start.

When you running an animation you keep track of your last point, your next point, and how far you are in between

them as a value between 0 and 1 we'll call this Interp. When your Interp get's to 1 your last position becomes equal

to your next position and you increment your next position through the animation. (this is sounding confusing to me)

I dont know exactly how your doing your animations right now so if described your system it would be easier for us

float animtimeflaot interpvalkeyframe frames[numframes]keyframe frameA, frameBkeyframe currentpositonint curframeResetAnimation{  frameA = frames[0]  frameB = frames[1]  animtime = 0  curframe = 0}IncrementAnimation (float T){  animtime += T  if animtime > frameB.start then   {     animtime -= frameB.start      curframe++     frameA[curframe]     frameB[curframe+1]     if curframe == numframes     {       ResetAnimation   //reached the end       return     }  }  interpval = (animtime - frameA.startTime) / frameA.length  currentposition = LinInterpolate(frameA, frameB, interpval)}

You need to modify it to handle an array of arrays of keyframes so

keyframe frames[numframes]

becomes..

keyframe frames[numtracks, numframes]

where numtracks are how many differnt animation tracks you have such as walk, run, jump, crawl would be 4

and you'll need to modify the soure to something like this..

float animtimeflaot interpvalkeyframe frames[numtracks, numframes]keyframe frameA, frameBkeyframe currentpositonint curframeint curtrackbool switchingtracks //set true if we're not in normal animationfloat switchlength   //how much time to get to the next trackResetAnimation{  curtrack = 0  frameA = frames[curtrack, 0]  frameB = frames[curtrack, 1]  animtime = 0  curframe = 0}GoToStartOfTrack(int track, float time){  if track > numtracks    return whaaat?  frameA = currentposition  frameB = frames[track, 0]  //start of next track  curtrack = track       //prepare for when we finish blend  switchingtracks = true //tell increment function we're blending  switchlength = time    //how long we have to blend  animtime = 0 //become how far through we are  curframe = 0 //prepare for when we finish blend}IncrementAnimation (float T){  animtime += T  if switchingtracks then  //begining of blending code  {    if animtime > switchlength then //we're done blending    {       frameA = frames[curtrack, curframe]   //basicaly do a reset animation with new track       frameB = frames[curtrack, curframe+1] //basicaly do a reset animation with new track       interpval = (animtime - frameA.startTime) / frameA.length //calculate interp       switchingtracks = false //done blending    }    else    {       interpval = (animtime) / switchlength  //this is a quirk, we have to ignore the frames lengths                                               //becasue we're on special time here    }                      //end of blending code  }  else  {    if animtime > frameB.start then     {       animtime -= frameB.start             curframe++       frameA[curframe]       frameB[curframe+1]       if curframe == numframes       {         ResetAnimation   //reached the end         return       }    }    interpval = (animtime - frameA.startTime) / frameA.length  }  currentposition = LinInterpolate(frameA, frameB, interpval)}

Obviously that code is not run-able but it should give you some ideas. If anybody notices anything obviously wrong

please corrent me, its hard to catch bugs if you cant compile.

Hope that clears some things up.

##### Share on other sites
Doesn't Midnight Club 3 use pixel shaders to do motion blur?

Well, whatever it is, it is the best motion blur I have ever seen in any game. It really gives you a sense of speed. Anyway, I think I did see something about that NVidia's site. I wanted to find out how that worked but I never got too it.

##### Share on other sites
Quote:
 Original post by T1OracleDoesn't Midnight Club 3 use pixel shaders to do motion blur?Well, whatever it is, it is the best motion blur I have ever seen in any game. It really gives you a sense of speed. Anyway, I think I did see something about that NVidia's site. I wanted to find out how that worked but I never got too it.

Some people are confusing motion BLUR as in giving the appearance of motion, and motion BLENDING as in seamlessly tranfering between sets of skeletal animation data.

##### Share on other sites
Oh, I thought it was a more interesting topic. Motion blending is easy, just use linear interpolation.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628388
• Total Posts
2982403

• 10
• 9
• 16
• 24
• 11