Inverse Kinematics: An approximate real time history

November 17, 2012 § Leave a comment

Hi, my name’s Sean Richardson, and I have a weird habit.

“Hi Sean.  The first step to recovery is acceptance.”

Why thank you disembodied voice, I was just wondering though, would you like to know about my slightly odd habit?

“Oh.  Uhhh, not really, if it’s all the sa-”

Great!  So, whenever I’m playing a third person game of any kind, I can’t help but stop my character on slopes, and look at their feet!

“I don’t know if that’s that odd, I mean, lots of people do that.”

Do they though?  Do they do it for the same reasons as me?  Do they really understand?  You know what, I can see it in your face, you’re confused, so I’ll explain.

“That’s really not-”

If you’ve ever stopped, looked down at your character’s feet, and thought “wow, that’s some good connection with the ground my character has” then you have Inverse Kinematics to thank for that.  Inverse Kinematics, you ask?  Well, it’s the opposite of Forward Kinematics!  Forward Kinematics is, for the simplest explanation, a process we do mentally every day.  We think to ourselves “I’d like my finger to be there, so that I can type the ‘f’ key” and so we move our muscles so that our finger is there.  In a computing sense, the idea is that you work out the position of something(like a finger) based on all the previous joints.

Inverse Kinematics, is of course, the opposite.  Inverse Kinematics ask “if my finger is here, where would every other relevant part of me be?”  Or, in most cases, it asks about characters feet.  In fact, their legs were so specific that an early paper outlining Inverse Kinemation in animation referenced legs specifically(Computational modeling for the computer animation of legged figures).  Personally, I started thinking about this recently, after noticing the effect in The Legend of Zelda: The Wind Waker, which was a particularly good implementation, especially for when it was written.

There are problems there, like when you stand with one leg off an object, and it’s also important to note that Wind Waker has an unfair advantage, which is the length of Link’s legs, which make altering the angle considerably easier when compared with someone of relatively normal proportions.  Like say, Link.

Oh, yeah, that’s right, Ocarina of Time featured Inverse Kinematics.  Remarkably, OoT wasn’t even the first game to feature IK.  So far as my research shows, that honour goes to Jurassic Park: Trespasser.  A pioneer in many fields, a jack of all trades, and a complete failure at everything, Trespasser, released in October of 1998(So it’s beating OoT by less than a month), animated all of its creatures using IK, rather than a more standard animation system.  To say that the results of this were laughable would probably be an understatement.

It’s interesting that a Jurassic Park game would be a pioneer in the field of IK, given 1993’s Jurassic Park film set the benchmark for animal animation through the use of Inverse Kinematics.

Of course, over the years the implementation of IK has improved significantly.  For instance, I was impressed when playing Half Life 2, when I noticed a Vortigaunt’s foot angled accurately on a ramp.  Guild Wars 2’s implementation manages to animate well with properly proportioned characters, and it also has a “reposition” animation which helps to mask the IK calculations, and stops the characters limbs from suddenly repositioning the moment they stop moving.

The best use, of course, goes to Grand Theft Auto 4.  Through its use of Euphoria, and the appropriate body based physics that allows, it has easily the best legs in gaming.  It’s a shame that they’re so hard to see thanks to its camera.  The animation system causes a change in how Niko moves if he’s going uphill or downhill, meaning there’s no awkward moment when he stops, and any IK attempts to kick in.  In fact, the engine even tries really hard to avoid awkward overhangs, by moving Niko’s legs so that he’s always standing on things.

It’s hard to tell from the image, but the back of Niko’s foot is just on the stairs, and any attempt to turn him sideways would fail.  Such a strategy should be applauded, given its flawless natu-

Hmm, oh.  Well, at least they tried(Again, my images are terrible, but in case it wasn’t clear, he is managing to hold his entire body weight on his right leg, while standing casually).

Obviously, Inverse Kinematics go well beyond simply feet, and how they sit on things, but as a very visible, and increasingly prominent element of games, I thought a brief look at them might be interesting.

Given the majority of this is pulled from Wikipedia, and my memory, it stands to reason that there may be things I missed, or oversights made(I find it hard to believe that nobody has made a comprehensive timeline of something so trivial), if so, I’d love to be proven wrong.  If not, well, I guess we can think about feet some more.


Graphical Optimisation, from a visual perspective pt. 1

October 9, 2012 § Leave a comment

(No, I didn’t post anything yesterday, but it was a public holiday, so I didn’t feel like it.  Hey, shut up, I don’t make up the rules, I just enforce them.  Wait, no, I do make them up, so HA, you’re not my real mum)

When it comes to optimising a piece of code, there are two main facets to look at, the underlying code, and its actual implementation.  The former is a relatively simple process, where you go through what’s written, and make it as easy to read as possible, and minimise or fix any points where the code is causing slow down.  The implementation side though, will often require a lot of lateral thinking, and repeated tests to ensure that what you’re doing is actually optimising.  For a visual example, think of a graphical effect, such as Screen Space Ambient Occlusion.  When you go to implement it, you’re left with a few options, pertaining to graphical quality vs. computational power.  Theoretically, the best quality option would be to have the most complex processing system, which takes into account as many light bounces as possible, and to render it at the full screen resolution(or its upscaled anti-aliased form, depending on what you’re dealing with).  Simple optimisations here are to use a simpler light bounce calculation, thus reducing the amount of processing power for each pixel calculated, and to render it at a lower resolution than your screen, with some form of upscaling.  You could run into problems if your upscaling required more power than it would take to render the whole screen, and you’re more likely to get odd artifacts from within the effect, but overall, so long as it’s implemented well, the difference to visuals should be negligible, while the performance would be greatly improved.

For a significantly more optimised form, we could look at what Sucker Punch Productions did for Infamous 2.  Given a normal pre-baked light occlusion system is efficient, but lacks good detail, and a normal real time one is inefficient, and often will fail at the “big picture” they decided to combine the two.  As such, they pre-calculated occlusion maps for objects, and then used a function to calculate when the maps should be shown.  This allows for great clarity within the occlusion, while also allowing it to be very accurate, and most importantly, optomised.  It has a relatively light-weight piece of code running on screen, and it would increase the amount of RAM required, by increasing the number of “textures” in use, it would also slightly increase developmental computing budget, but to a point that should be unnoticable in terms of a full retail game.  This system however was designed to complement the existing AO, rather than replace it, in particular its uses were for medium distance, static objects, due to limitations of the pre calculation system(Compared to the long distance, static for pre-baked, and short distant,dynamic of SSAO).  However, in theory, the work that went into making it a complementary system, could be significantly refined to allow it to replace any form of real time occlusion calculation, or at least to significantly reduce the amount of calculation required for a normal visual appearance.  Regardless of its implementation, such optimisation is an important logical step.

But I want to go a little further with optimisation, that is, to put it into the truly visual spectrum.  For this, it’s important to look at another piece of visual work that takes a lot of time to create.  That is, cartoons.  More specifically, I was looking at anime, which takes many of the tradtional cartoon systems, and further refines them, and it occurred to me that certain changes to how video game graphics are shown could be made, which may help reduce the amount of time spent making them, and the amount of time it takes to render them.  Obviously, this is not a be-all-end-all solution.  There will always be space for hyper “realistic” games, and their greys and browns, but this train of thought would work best with anything from the “Uncharted 2” level of stylisation, right down to El Shaddai: Ascension of the Metatron(As is stands, Uncharted 2 is an almost perfect example of what I’m suggesting.  Obviously, my ideas aren’t new, but I wanted to clarify them on paper).

Tune in at some point in the future, where I get into better detail, and am hopefully less tired, and so I write better.

Down the Loopers Loop, Part One

October 3, 2012 § Leave a comment

Having recently seen Looper(A good movie, in my humble opinion), I thought now was as good a time as any to look at the common forms of theorised time travel, while I attempt to get my head around exactly what kind of internal consistency it used(Some of what is posted here may constitute spoilers, though none of them at this time are for Looper).


“There are fixed points in time.”

So, let’s start with the very simplest concept of time travel, that is to say that time is fixed.  This theory, while long-standing in fiction, is simple enough to understand through what is known as the “Novikov self-consistency principle.”  This follows the very simple idea that any event that has the option of changing the timeline has a null chance of happening, so a time paradox simply cannot exist.  A well known example would be that of the time turners from Harry Potter, they go back in time, constantly worrying about causing some sort of paradox, but all their events have already happened in the past.  Harry is saved by himself, and that’s always the case.  This theory typically leads to questions about free will, as if the timeline is set, then nothing you do can change that.  This itself comes in two main forms, either the idea that everything that could ever occur in time is already pre-set, or simply that everything “behind” some notion of the “present” is pre-set, with free will allowed only to those who do not travel backwards.  Travelling forward in time via this second theory becomes rather complex though, as you move to a point where your present is the past, thus forcing a “fixed” future, and so removing any attempts at free will.


“Time can be rewritten.”

Moving on to the second main concept of time travel, we get the idea that there are no set points, and that anything in time can be changed.  The important part of this theory is that everything exists in one timeline.  Though, it would be more apt to call this a grouping of theories, as there are many different ideas within it.  In something like Back to the Future, almost everything Marty does affects the future in some way, with the changes affecting the future in approximate relation to the size of the change.  By knocking down a tree, he changed the name of a park, but by teaching his father to be brave, he causes big changes to his family in his present.  He as a character is also set throughout this(excluding the paradox which almost causes him not to exist), with a vision of him in the future allowing him to change his actions in his own near future, thus preventing that future from happening.  In this case, it’s avoiding a grandfather paradox in his own future, while also accepting that it could happen within his own past.  Another theory here is that time is resistant to change, so while you could go back to try and stop Lincoln from being assassinated, you would ultimately fail, but what you’ve done within that time, your appearance there, and so forth, could have subtle implications on the present, like a different pain colour on someone’s shed, or change to someone’s socio-economic status.  This also wouldn’t be a decent time travel piece if I didn’t mention “The Butterfly Effect(the film)” which runs off the idea that any minute change will have sweeping differences over time, also see the “Time and Punishment” section in the Simpsons.


“I can’t think of an appropriate approximate Doctor Who quote to go here.”

The third (and final) main theory of time travel that exists is the multiple universe theorem(or what is sometimes referred to as the Trousers of Time).  Typically, this runs off the idea that any time a change occurs, this causes a new universe to be created from that point forward, and any new changed from there onwards cause another split.  This theory is typically more internally consistent than the others, as it makes for a set “character” who travelled back in time, and cannot alter their own past, but they are able to alter a different them’s past.  A good example would be Dragon Ball Z, where characters travel back in time to warn other characters of future events.  Trunks travels back in time to warn other people of their deaths, and in doing so, prevents them from dying, but only in the timeline he travelled to.  In his personal past, they are all still dead.  This theory also deals the most easily with the Grandfather Paradox, as you’re not killing your own Grandfather, but killing that of a different you, preventing that universe’s you from existing.


There are also a whole lot of other ideas that don’t quite fit into a neat category.  One of my favourites is the idea of “beads of time.”  This theory, while completely impractical from a writing point of view, is a lot of fun.  If you were to imagine that time is like a beaded necklace, with every point in time being a bead, the theory states that by travelling back in time(let’s say to a field), all you’re doing is removing the existing beads until you reach the point you choose, where the beads start going on again.  Typically, this would fall under the second theory.  Unfortunately, of course, if you imagine that the beads go back up to what had once been your present, the you of there is still there, and would still decide to time travel back to that field, at that time, and all of a sudden there’s an infinite number of you attempting to fill a finite amount of space, and there’s a whole lot of problems.  This theory does allow for travel forward though, as you’re simply adding more beads.  The point of this is to help reinforce a very simple idea.  That is to say that going backwards in time is impossible, but that maybe, just maybe, forwards could be done.  Though there’s always the donut idea of time, as presented in Futurama, where they travel forwards through time until the universe repeats, and they’ve essentially travelled backwards.


Obviously, I don’t have a degree in physics, I can’t talk about how probable any of these ideas are, but hopefully this gives you a decent idea of some very, very basic ideas of time travel.  Now get yourself ready for part two, where I actually discuss Looper.

Resolution and Scaling: Wild Theory

June 12, 2012 § Leave a comment

They say that communism works, in theory.  So I’m going to roll with a little thought exercise here.

I read a piece a while back, detailing how the author believed that PC gamers were being “self-entitled” by demanding that they be able to run games at 1080P 60, and the author made claims about the quality of films, particularly those in the Blu-Ray format, to do with its typical 24fps rate, and detailed stuff to do with the quality on screen.  For the life of me, I can’t remember where I read it, but an interesting point was raised, namely that we should be aiming for photo-realistic quality(technically a more accurate term would be “pixel-perfect,” that is that no “blemishes” are shown), but at 1280 * 720, instead of the usual 1920 * 1080. « Read the rest of this entry »

The Maths of Pixels.

June 7, 2012 § 2 Comments

This is a fairly short post, just to describe the maths behind “size” of video files, specifically in their uncompressed form.  Obviously, the number here have no real world application, but I find it interesting.

Specifically, we’re looking at something running at 24fps, and running on what wikipedia says is 2k resolution for cinemas, 1998 × 1080, which is a 1.85:1 aspect ratio, not that that’s related, oh, and let’s say we’re dealing with a 2 hour long movie, which is running in 3D.

So, if we have a 1998 x 1080 screen, we’re dealing with 2,157,840 pixels on screen.

Let’s assume that each pixel is running in 32 bit colour, so we have 69,050,880 bits on each frame, which is (divided by eight to get) 8,631,360 bytes in each frame(obviously, the simpler equation is just to multiply the bits by 4 to get 32 bits as bytes).

There are 48 frames every second(24 frames, twice, to deal with 3D), which means we have 414,305,280 bytes every second.

With sixty seconds in every minute, we have 24,858,316,800 bytes every minute.

With one-hundred and twenty minutes in two hours, we have 2,982,998,016,000 bytes for the whole film.

There are 1024 bytes in a kilobyte, so if we divide by 1024 we have 2,913,084,000 kilobytes.

The same applies for kilobytes into megabytes, so it’s 2,844,809 megabytes.

Funnily enough, the same as above applies to get gigabytes, so it’s 2,778 gigabytes, or 2.7 terabytes.

Unless I’ve made a mistake in my maths here, which is entirely possible.

Where Am I?

You are currently browsing the Tech category at An Occasional Blagh.