• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
keym

SLERP issues

10 posts in this topic

So I implemented (finally) my GPU skinning and it works well when I iterate through all frames. It even works when I interpolate between frames of the same animation but I wanted to push it forward and make a simple weight based blending between animations. Here's the problem... Check out the video:

 

http://www.youtube.com/watch?v=HX0Rv8X5TC0

 

For this particular test I'm "slerping" current frame with bind pose frame at ratio 0%-50% (weight increases as I continue to play walk animation, I capped it to 50% because here is where the weird stuff is most noticable). When I SLERP between frameN and frameN+1 accordingly to the elapsed time, animation looks alright. The problem occurs when I try to blend two animations or animation with bind pose (as shown in the video). Ideas?

0

Share this post


Link to post
Share on other sites

From the video it kinda looks like you're simply lerping euler values? (and then converting to quat?). Or converting to eulers from quat, and then lerping those? I'm a bit confused as to what your problem is? (since you haven't actually stated it). You seem to have some really dodgy animation cycles with a lot of popping in them? Those 'pops' you keep having seem to be there at the start (when you're at 100% anim?). Just looks like dodgy source data to me. Are you getting the values from fbx by any chance?

Generally blended anims looks best when they are relatively similar - so a bind pose + walk is never going to look that good. I'd probably recommend using nlerp instead of slerp when actually blending the anims themselves (it's fine to keep slerping between keys, but when blending multiple anims, nlerp is easier). When nlerping a bunch of anims, sum the weighted quats, and normalise as a final step. Beyond that, more info needed.....

0

Share this post


Link to post
Share on other sites

No, I'm using slerp on quaternions and lerp on bone position vectors. Model is loaded from id tech4 format (md5mesh+md5anim format). All works good when I interpolate between frames of the same animation. It start's to act strangely when I try to interpolate between frames of two different animations (or for instance with bind pose, it doesn't really matter if it's bind pose or not, believe me, I get similar "pops" when I use other animation instead of bind pose).

Edited by keym
0

Share this post


Link to post
Share on other sites

I'm a bit confused as to what your problem is? (since you haven't actually stated it).

 

For this particular test I'm "slerping" current frame with bind pose frame at ratio 0%-50% (weight increases as I continue to play walk animation, I capped it to 50% because here is where the weird stuff is most noticable). When I SLERP between frameN and frameN+1 accordingly to the elapsed time, animation looks alright. The problem occurs when I try to blend two animations or  animation with bind pose (as shown in the video). Ideas?
0

Share this post


Link to post
Share on other sites

Now assuming what you've said is correct, if at the start of the video you are just displaying the animation (100% anim, 0% bind pose), then to me, it looks like your source animation is crap (because at the very start of the video it's popping way too much). The other alternative is that you're using a very ropey slerp function? Have you tried using nlerp (with shortest path correction)? At least then you can maybe *start* to rule out some possible causes? Slerping key frames to create a walk cycle, and then slerping that with a bind pose, will not, in of itself, produce any popping (although it will never look very good).

FWIW, I've been an animation programmer in the industry for over a decade. When I say you've failed to state the problem, I literally mean just that. Subjective terms such as "wierd stuff" is not a very useful way to describe any problem, especially not when dealing with animation blending - for all I know, the animator could have intentionally made the anims look like that! (You'd be surprised what some of the animations animators create!).

0

Share this post


Link to post
Share on other sites

First of all I doubt that the animation is wrong - it's directly ripped (for educational purposes only!) from Doom3 (directly meaning from the pk4 file, not downloaded from some crappy site). Walk cycle looks ok when played itself.

 

As I have written, that blending is capped to 0-50%, meaning at max we have 50%-50% of animation-bindpose mix and at min we have 0-100% proportion (no animation, just plain bind pose - parts of the vid where the model is not moving). I did it to emphasise where the problem occurs. If I would do 100%-0%, most of the time you would just see the original walk animation without popping. At the beginning of the video you see roughly 50%-50%.

 

I tried with Nlerp but it looks even worse - body is completely dismembered and limbs are spinning in various directions and I'm like WTF.

Edited by keym
0

Share this post


Link to post
Share on other sites

No, I'm using slerp on quaternions and lerp on bone position vectors.

 

Are you lerping the bone positions in world space? If so, then that's the problem, you should be constructing bone positions at the end based on your skeleton hierarchy, bone offsets, and bone quaternions.

0

Share this post


Link to post
Share on other sites

I'm interpolating in object space. Does this require rebuilding bone positions from hierarchy as well?

 

And my SLERP looks like this:

quaternion quaternion::slerp(quaternion q1, quaternion q2, float percent)
{
    quaternion result;

    float dot = q1.dotProduct(q2);              //Dot product - the cosine of the angle between 2 quats
    if(dot < -1) dot = -1;                      //Clamp value to [-1,1], just to be sure
    if(dot > 1) dot = 1;
    
    if(dot < 0)                                  //If cos(angle) is <0 we negate the quaternion and dotp.
    {                                            //(Go with smaller rotation)
        q2=-q2;
        dot=-dot;
    }

    if(dot > 0.99 && dot < 1.01)                 //If dotp is close to 1, do Lerp
    {
        result = q1 + ((q2 - q1) * percent);
        result.normalize();
        return result;
    }

    if(percent < 0.01)                           //If percent is close to 0, return quat1
    {
        result = q1;
        return result;
    }

    if(percent > 0.99)                           //If percent is close to 1, return quat2
    {
        result=q2;
        return result;
    }

    float a = acos(dot);                         //Get angle between quats
    result = (q1 * (sin((1.0 - percent) * a) / sin(a))) +  ((q2 * sin(percent * a)) / sin(a));
    return result;
} 
Edited by keym
0

Share this post


Link to post
Share on other sites

You need to normalise the result. 

 

Also... since I'm writing - your variable "percent" is named very confusingly. One would expect anything called percent to range (typically) from 0-100. 

0

Share this post


Link to post
Share on other sites

Unfortunately normalising doesn't make a diffrence. I guess it only matters with (n)lerp anyway. I'm starting to think that maybe I should rebuild the positions, as C0lumbo suggested (even though I'm lerping in object space...), but not sure where to start with that.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0