Making of Clear Skies 3: Animation Perspective Part 2.

This post is going to quickly go over the two methods I used to actually get the animations into Source.

Method 1: BVH

Ipisoft exports to the BVH format, which is one of the standard motion capture formats. It stands for Biovision Hierarchy, and it was developed by Biovision, who went bust a while ago. This is the best format in my opinion, because it is very easy to read and parse.

A BVH file has two parts:

  1. the hierarchy itself, which describes the skeleton and initial pose.
  2. The transformations that the skeleton goes through to animate it.

The hierarchy starts with the ROOT node, which for humans is usually the centre of gravity. The hierarchy itself is recursive: each node contains data relevant to it (like position, rotation), and further subnodes.

The position of the node is defined by it’s offset from it’s parent, not an absolute position in the world. If it was absolute, it wouldn’t move when it’s parent moved. You’d move your arm, but your hand would remain on the desk.

The rotation of the node is defined as the rotation relative to it’s parent.

There exist a massive amount of tools for reading and manipulating this data, so I didn’t really need to write another one. It was a good job too – I was struggling with the XSI Mod tool.

XSI Softimage is the suite that Valve origianlly used for modelling & animating Half-Life 2. In 2004, when Half-Life 2 was released, XSI had a free, cut down version of the tool for Modders. It was called the XSI Mod Tool.

Valve also created a whole bunch of addons for it, to export stuff to the Source Engine.

Since Softimage got bought out by Autodesk, the free versions are less and less useful, the tools are out of date and features get locked off. You can find the old versions around, but it’s difficult and they are not supported much.

I’ll do a quick tutorial on it here anyway.

Autodesk Softimage Mod tool 7.5

You’ll need to find the ValveSource addons for Softimage, which are either on the net, or in the Source SDK folder.

Open the XSI Scene file “SDK_Male_reference.scn” which can be found in “C:\Program Files (x86)\Steam\steamapps\USERNAME\sourcesdk_content\hl2\modelsrc\humans_sdk\XSI_scn_files” or similiar.

You should get this chap:

 

He’s very low in IQ and poly count, but he’s lovable just the same, because he’s ideal for testing stuff out.

Press “8” on the keyboard to bring up the scene expolere, and middle click on the “Valve Biped” node.

Middle clicking recursivley selects everything inside the node.

Go to Animate->MOTOR->Tag Rig

This will bring up the tag rig dialogue. It defaults to a human biped, and has  entries for all the major bones.

You need to go through each diagloue, click the bone name button, eg “cog”, and select the corresponding bone on the human skeleton.

Here is an example:

I’ve chosen centre of gravity (cog) as Bip01_Pelvis. Most of them are easy enough to work out, but get it wrong and the animation will be….funky.

Once you’ve finished tagging the rig, SAVE it…it will save you a vast amount of time.

You then need your BVH.

There is a large library of free ones here.

Tagging the BVH rig

Go to Animate->MOTOR->Mocap to Rig

You’ll get this dialgoue:

You need to

  1.  Select BVH as the format
  2.  Select a BVH file
  3.  Create a tag template This will launch the same window as previosuly. This time, you want to tag the BVH you’ve just loaded. Once done, save this one too.
  4.  Select Target Model This should already be the ValveBiped, if not, select it from the Scene Explorer.
  5. Apply.

I’ve uploaded my Valve Biped tag file and by BVH tag file here, as well as a mocap file I took from the site mentioned earlier. Link: http://daft-ideas.co.uk/rnd/Clear%20Skies/mocapeg/

Now, by the power of greyskull, you’ll animate the Valve Biped:

This is rendered from Softimage, because while making this post I couldn’t be bothered to export the skeletal animation into the Source Engine.

I’ll cover how to actually get this into game next post. This was meant to be quick, but oh well. I still need to cover the other method I used 🙂

Making of Clear Skies 3: Animation Perspective.

Clear Skies is a feature-length machinima series from Ian Chisolm, that won a load of awards. You can find them all here: http://www.clearskiesthemovie.com/

It’s filmed in the Source Engine, using the unbelievably powerful but oft-incomprehensible SDK, and Eve Online. All the indoor bits, involving people, are done with Source, and all the space scenes are filmed in Eve.

When the second part was done filming, I was introduced to Ian, who wasn’t sure about making a third, but he did mention the frustrations he was having with the limited animation set of the Source Engine.

I told him that I thought it was possible to create our own animations, even to use Motion Capture to do the hard work for us.

It even turned out to be possible to use completely markerless MoCap.

Shoot3d (now known as Ipisoft), have a markerless system that has a unique advantage: it can export directly to SMD, Source’s uncompiled model / skeletal animation format, making it much easier to import new animations into the game.

Before I tried my hand at doing my own Mocap, I took some BVH files and tried mapping them to a Source Engine Human Skeleton myself, and testing the results out in game.

This turned out to be a daunting task. I knew very little about skeletal animation, and getting the mappings right took some time. I had a small amount of help from http://www.youtube.com/user/mm3guy, who gave me some pointers in getting the BVH working correctly.

My first success can be found here:

Once I’d got this process working, I tried out Ipisoft’s Mocap software.

For this I used:

  • An old mini-DV camera, with bad interlacing
  • A cluttered barn
  • Myself

Which was unfortunate, because they recommend using none of these things.

They recommend:

  • Multiple HD cameras
  • An uncluttered environment with little to nothing in the background
  • Somebody who is not me.

Undaunted, I tried anyway.

The chap visible in the video is Pope, who helped me out on the early tests. He was responsible for herding cats on Clear Skies 2.

We also made him do the robot:

IPISoft did a really good job of interpreting the image, and it’s results can be seen here:

Actually adding this stuff to a model in HL2 is not easy or straightfowards: in some cases you have to decompile the model, which breaks all kinds of stuff, most importantly the facial flexes.

Not ideal when you’re relying on the power of the Source Engine to bring the models to life.

Still, the earliest result I could find is here:

Not bad, for a beginning. More to follow, on the rest of the process.

 

 

 

Leaving Tenerife

Finished my diving trip now, and I’m flying back to sunny Manchester tomorrow afternoon.

I’ve managed to do 7 dives this week, which is three less than I should have done. I had to can a dive this morning because of a equipment malfunction, and I missed a day due to blocked sinuses.

The dives I have done, however, have been very fun. I’ll post some pictures and a more complete log of what I’ve been doing soon.

-Tenerife Scuba, fueled by caffeine.

Diving

Made it to Tenerife, and learned a few things along the way:

  1. Don’t forget to check in online when flying ryanair. They WILL charge you for your foolishness.
  2. Get travel insurance BEFORE leaving the country. Most travel insurers will not offer diving insurance on its own. I solved this by signing up with Dive Assure, on  a seven day policy. We’ll see how this pans out.
  3. Don’t dive with the remnants of a cold. No matter how much you think you’re better. You’re not, and your sinuses will punish you for it. Idiot.

I might get to go on a night dive this week. Excited and nervous about it. I might get a cheap underwater camera at some point, and stress test it.

Rockpapershotgun, and Horace, the endless tech.

http://www.rockpapershotgun.com

RPS is down. Or maybe replaced. Instead, there is a text adventure game there:

503 – Service Unavailable
An Interactive Fiction by Horace The Endless Server Technician
Release 1 / Serial number 110707 / Inform 7 build 6E72 (I6/v6.31 lib 6/12N)

HTTP Error
You are standing at the entrance to Castle Shotgun. The gates are securely locked, with an unappealing sign on the front. The sign reads “Whoops! RPS is having a bit of a wobbly. Don’t worry, we’ll be back soon!”

To the left of the gates is a large opening in the wall, which Jim is leaning into. John is perched on a small rock nearby, while Alec and Tim are standing on the other side of the gates. A pile of magazines is scattered in a corner.

You can see Jim, John, Tim, Alec and a Refresh Button here.

>refresh
That’s not a verb I recognise.

>look
HTTP Error
You are standing at the entrance to Castle Shotgun. The gates are securely locked, with an unappealing sign on the front. The sign reads “Whoops! RPS is having a bit of a wobbly. Don’t worry, we’ll be back soon!”

To the left of the gates is a large opening in the wall, which Jim is leaning into. John is perched on a small rock nearby, while Alec and Tim are standing on the other side of the gates. A pile of magazines is scattered in a corner.

You can see Jim, John, Tim, Alec and a Refresh Button here.

>go north
You can’t go that way.

>go south
You can’t go that way.

>go s
You can’t go that way.

>go up
You can’t go that way.

>sleep
You aren’t feeling especially drowsy.

>eat
What do you want to eat?

>eat shoes
You can’t see any such thing.

>look
HTTP Error
You are standing at the entrance to Castle Shotgun. The gates are securely locked, with an unappealing sign on the front. The sign reads “Whoops! RPS is having a bit of a wobbly. Don’t worry, we’ll be back soon!”

To the left of the gates is a large opening in the wall, which Jim is leaning into. John is perched on a small rock nearby, while Alec and Tim are standing on the other side of the gates. A pile of magazines is scattered in a corner.

You can see Jim, John, Tim, Alec and a Refresh Button here.

>eat cast,e
You can’t see any such thing.

>eat jim
(first taking Jim)
I don’t suppose Jim would care for that.

>eat John
(first taking John)
I don’t suppose John would care for that.

>eat Tim
(first taking Tim)
I don’t suppose Tim would care for that.

>eat Alec
(first taking Alec)
I don’t suppose Alec would care for that.

>look at Alec
On closer inspection, Alec appears to be gluing bits of Warhammer 40k model armour to his shoulders and chest.

He picks up a plastic lascannon and tries it out on his left nipple.

>look Jim
His top hat and procedurally-generated facial hair gives him away in a second – this is Jim Rossignol, wordsmith and crazed steampunk inventor.

Jim is hunched over an opening in the Castle Shotgun walls, from which various wires are trailing. There is the occasional spark and fizz as he rummages around.

>look John
John sits hunched over on a stone at the foot of Castle Shotgun’s walls, head in hands groaning to himself. There are several empty rum bottles nearby, one of which appears to have an Asda logo on it.

>drink rum
You can’t see any such thing.

>look Tim
Tim is standing on a small outcrop, binoculars in one hand, looking out eastwards. Unfortunately, east of here is just the M4 corridor, but east is the direction heroes look in, as evidenced by his stony glare.
He takes a deep breath. “I love the smell of Bath in the morning.”

>talk Tim
I didn’t understand that sentence.

>look
HTTP Error
You are standing at the entrance to Castle Shotgun. The gates are securely locked, with an unappealing sign on the front. The sign reads “Whoops! RPS is having a bit of a wobbly. Don’t worry, we’ll be back soon!”

To the left of the gates is a large opening in the wall, which Jim is leaning into. John is perched on a small rock nearby, while Alec and Tim are standing on the other side of the gates. A pile of magazines is scattered in a corner.

You can see Jim, John, Tim, Alec and a Refresh Button here.

>pickup Tim
That’s not a verb I recognise.

>pick up tim
I don’t suppose Tim would care for that.

>talk alec
I didn’t understand that sentence.

>look alec
On closer inspection, Alec appears to be gluing bits of Warhammer 40k model armour to his shoulders and chest.

Alec clears his throat and tests out his Librarian imitation. It’s not bad.

>help
That’s not a verb I recognise.

>die
That’s not a verb I recognise.

>kill
What do you want to kill?

>kill Alec
Violence isn’t the answer to this one.

>kill Jim
Violence isn’t the answer to this one.

>Kill seld
You can’t see any such thing.

>Kill self
Violence isn’t the answer to this one.

>kill me
Violence isn’t the answer to this one.

>talk me
I didn’t understand that sentence.

>look
HTTP Error
You are standing at the entrance to Castle Shotgun. The gates are securely locked, with an unappealing sign on the front. The sign reads “Whoops! RPS is having a bit of a wobbly. Don’t worry, we’ll be back soon!”

To the left of the gates is a large opening in the wall, which Jim is leaning into. John is perched on a small rock nearby, while Alec and Tim are standing on the other side of the gates. A pile of magazines is scattered in a corner.

You can see Jim, John, Tim, Alec and a Refresh Button here.

>talk to jim
Jim doesn’t take his head out of the hole in the wall. You hear him muttering to himself.

“Yes, it must be the… no, unless it’s the… Hmm.”

>talk to john
John looks up. “Hmm? No, I didn’t lock us out. We’re just having a bit of trouble with Horace. We’ll have it working again in a tick.”

He resumes nursing his headache.

>talk horace
I didn’t understand that sentence.

>talk jogn
I didn’t understand that sentence.

>talk to john
John looks up. “Hmm? No, I didn’t lock us out. We’re just having a bit of trouble with Horace. We’ll have it working again in a tick.”

He resumes nursing his headache.

>talk to tim
You don’t feel like talking tactics right now, and Tim is looking rather intense at the moment.

>look tim
Tim is standing on a small outcrop, binoculars in one hand, looking out eastwards. Unfortunately, east of here is just the M4 corridor, but east is the direction heroes look in, as evidenced by his stony glare.
He pulls out a script from “Patton” and flicks through it, mouthing a few lines to himself.

>talk to alec
Alec seems a bit involved with sticking plastic armour to himself to reply. It’s probably best to leave him alone when he’s arming up, anyway.

>look
HTTP Error
You are standing at the entrance to Castle Shotgun. The gates are securely locked, with an unappealing sign on the front. The sign reads “Whoops! RPS is having a bit of a wobbly. Don’t worry, we’ll be back soon!”

To the left of the gates is a large opening in the wall, which Jim is leaning into. John is perched on a small rock nearby, while Alec and Tim are standing on the other side of the gates. A pile of magazines is scattered in a corner.

You can see Jim, John, Tim, Alec and a Refresh Button here.

>pick up magazines
They’re not yours to take, really. I’m sure no-one would mind you looking at them though.

>look at magazines
You grab a magazine at random. It’s the latest issue of Your Cat magazine! You’ve read this issue at least four times though, so you put it back.
You notice an old copy of Amiga Power in the pile.

>look at amiga power
An old copy of some obscure, arcane tome. The glyphs on the front are mysterious, and appealing.

>look at glyphs
You can’t see any such thing.

>read glyphs
You can’t see any such thing.

>read amiga power
An old copy of some obscure, arcane tome. The glyphs on the front are mysterious, and appealing.

>look
HTTP Error
You are standing at the entrance to Castle Shotgun. The gates are securely locked, with an unappealing sign on the front. The sign reads “Whoops! RPS is having a bit of a wobbly. Don’t worry, we’ll be back soon!”

To the left of the gates is a large opening in the wall, which Jim is leaning into. John is perched on a small rock nearby, while Alec and Tim are standing on the other side of the gates. A pile of magazines is scattered in a corner.

You can see Jim, John, Tim, Alec and a Refresh Button here.

>look at wall
You peek at the hole in the wall. There is a mess of wiring and tubes, and what appears to be the midriff of a particularly long animal. You peer down the inside of the wall in both directions, but see no evidence of legs or a head. Weird.

>look at wires
You can’t see any such thing.

>look at mess
You can’t see any such thing.

>look at tubes
You can’t see any such thing.

>look at animal
You can’t see any such thing.

>look at midriff
You can’t see any such thing.

>look at wall
You peek at the hole in the wall. There is a mess of wiring and tubes, and what appears to be the midriff of a particularly long animal. You peer down the inside of the wall in both directions, but see no evidence of legs or a head. Weird.

>look
HTTP Error
You are standing at the entrance to Castle Shotgun. The gates are securely locked, with an unappealing sign on the front. The sign reads “Whoops! RPS is having a bit of a wobbly. Don’t worry, we’ll be back soon!”

To the left of the gates is a large opening in the wall, which Jim is leaning into. John is perched on a small rock nearby, while Alec and Tim are standing on the other side of the gates. A pile of magazines is scattered in a corner.

You can see Jim, John, Tim, Alec and a Refresh Button here.

>open gates
You can’t see any such thing.

>look at castle
You can’t see any such thing.

>look castle
You can’t see any such thing.

>look magazines
You pick up one of the magazines. It’s the latest issue of Guns And Conversation, John and Jim’s fanzine that they distribute around Bath. The cover story promises “Semi-autos and small talk” and an interview with a man who has invented a talking gun.
You notice an old copy of Amiga Power in the pile.

>pick up amiga power
You reach for the magazine, but as you touch it it disintegrates in front of your eyes. In its place are the feet of a man. That man is Kieron Gillen. He smiles down at you.

>talk kieron
I didn’t understand that sentence.

>look kieron
Kieron’s figure is hard to make out, as his very flesh appears to emanate a glowing white light. He floats approximately two inches off the ground, and is wearing glasses which, when peered into, appear to reflect visions of the future and past.
He still looks a bit like Jason Statham though.

>talk kieron
I didn’t understand that sentence.

>talk to kieron
You open your mouth but the words fail to come. Without speaking, Kieron’s voice echoes inside of your head. He mentions something about Thief. Everything is right with the world.

>look
HTTP Error
You are standing at the entrance to Castle Shotgun. The gates are securely locked, with an unappealing sign on the front. The sign reads “Whoops! RPS is having a bit of a wobbly. Don’t worry, we’ll be back soon!”

To the left of the gates is a large opening in the wall, which Jim is leaning into. John is perched on a small rock nearby, while Alec and Tim are standing on the other side of the gates. A pile of magazines is scattered in a corner.

You can see Kieron, Jim, John, Tim, Alec and a Refresh Button here.

This is the most fun I’ve ever had on a 404 page.

A new beginning.

When I tried to start writing posts on Raytracing, the idea was to document my steps. The problem was, that when I started,  I’d already finished the project.

When I say finished the project, what I actually mean is ” I got too bored, stuck, or distracted to continue.”

I hadn’t planned the code out very well, and as I added new things I had to break old things, and it turned in to a stack of kludges built on kludges. It was kludges all the way down. It may as well have been held together with gaffa tape.

So I’m going to start again, and this time plan it a bit better, and I’m also switching languages. And I’ll post on my progress, because even though no one is reading this, I can still refer back to it.

In memory of this occasion, here are some snapshots of what I achieved. They’re not all very good, and some of them are downright weird.

Early code, with bad lighting and only one type of object. Orthographic camera.

Can’t remember what the hell happened here. Early plane intersection code, I think

A cock up, but an attractive one, as they go.

Plane intersection code still making things difficult.

Yeah. Not sure about this. Lighting problem? Plane seems to work though.

Plane intersection working, with some randomisation of the “up” vector,

Showing only the phong exponent of the scene.

Polygon intersection test. Weird bug if two polygons lie on the same plane.

Fixed bug. Can’t actually remember what it was.

With polygon intersection tests working ( or so I thought ), I turned my attention to loading an OBJ.

After a long struggle with weird bugs, ta-fucking-da. Also, transparency.

Rabbit model without any normals calculated.

Also, persitent shadow bugs. These eventually turned out to be the plane intersection code playing up. Again.No ordinary rabbit! Normals calculated.Glass onion.

Wizards!

So there we have it, a long line of bugs, and some pretty pictures.

The next version will have all kinds of cool optimisation! (I hope.)

What I want to achieve:

  • Faster OBJ loading
  • BVH tree for scene divisions. Should dramatically speed up rendering.
  • Distributed ray tracing:  soft shadows, depth of field, etc.
  • An easier to steer camera, and possibly some animation, to produce videos. Not in real time.
  • Photon mapping. This can be bolted on top, I think.

Raytracing Part 1: First Steps

Ray tracing theory is simple, but I’ll explain it anyway. Ray tracing is a generic technique, that can be applied to a lot of different things. I’m applying it to one thing- graphics.
(If you want a better overview than this, look elsewhere. Look at wikipedia. Ask someone.)
Simulating light is far too complex to be done “properly”. If you think about the sheer number of photons that are output by a light source (the sun), and the number of bounces each photon goes through, depositing energy each time it does, before finally arriving at your eye, or camera, you’d see why it’s not possible. At least, not at the moment. If instead, you ignore light being emitted from the sun, and instead trace the photons backwards- from your eye, into the world, you are faced with a much easier challenge.
**Some notation. I’ll be using the word eye and camera interchangeably. When I use the word “scene” I’m refering to the environment that the ray’s interact with.**
If you know you wish to render an image of 800 by 600 pixels, that’s 800*600 rays you have to trace.
  1. For each pixel, shoot a ray into the scene.
  2. Test the ray for intersections with every object in the scene.
  3. Find the closest intersection.
  4. Find the colour of that pixel.
  5. Rinse and repeat, until each pixel has been done.
Object Intersections.
The simplest kind of object to test a ray against is a sphere. This is nice, because real-time applications running in OpenGL or DirectX fail miserably at perfect spheres. They have to be rendered as a flat sided object, with lots and lots of sides.
Ah yes – some maths.
A ray can be defined as two vectors: an origin and a direction vector. The direction vector should be a unit vector.
ray = origin + direction
A sphere can be defined as position vector (which describes the pos of the centre) and a radius. That’s all:
sphere = centre + radius
A sphere with centre (x0, y0, z0) and radius r is the locus of all points (x, y, z) such that
\, (x - x_0 )^2 + (y - y_0 )^2 + ( z - z_0 )^2 = r^2.
Finding the Intersection:
A set of points on a ray can be defined by:
Ray(t) = ray(origin) + ray(direction) * t
Where t is the distance from the ray origin.
The ray equation can be substituted into the sphere equation, and solved to find t.
This takes the form of a quadratic equation. If you don’t remember quadratic equations from whatever secondary school maths equation, they take this form:
ax^2+bx+c=0,\,
So, substitution for ray:
X = X(ray(origin)) + X(ray(direction)) * t
Y = Y(ray(origin)) + Y(ray(direction)) * t
Z = Z(ray(origin)) + Z(ray(direction)) * t
Insert X, Y, Z into sphere equation:
(X)2 + (Y)2 + (Z)2 = R2
Solve this quadratically, to find t.

There. That was easy.
So, the first thing I did was to define a scene composed of a single sphere, no lights, and shot rays at it through an orthographic camera. All this accomplished was a sense of self satisfaction, as I watched some text in my console, proving that some pixels came back as “hit”, and some came back “miss”. At this point I had no way to show the results on screen.
I could show you the results of this…..but why?
The second thing I did was start hunting around for a way to display my output. Image libraries were out- I thought they might be too complex to learn to use. I simply wanted to define a window of the correct size, and use something like “setPixel”. I eventually, after much google-fu, gave up and used the windows API instead. This felt like a small betrayal (I’m mostly a linux user for coding). It did however allow me to produce this:
Ah. A black screen.
After some more fiddling, this happened:
Hurrah! I had ray-traced my first scene.
Admittedly, is has no lighting, no shading, no support for more than a single sphere, no support for anything other than spheres……The list of things it doesn’t do goes on.
It DOES get better.

Ray Tracer Part 0: Introduction

Everyone and their dog, and their dog’s mum, has built a raytracer. This is not surprising: I mean, seriously, it’s not that hard, and it looks REALLY SHINY. So, despite the fact that everyone has already done this, and in many cases done it better, now it’s MY turn.

I started this project in my final year at Univeristy, during an Advanced Graphics module. I did this because the module was theory, and theory only.Now I like building stuff, but not everyone else does, so I was probably alone in wishing for more brain melting coursework. Also, the theory was hard. Very hard.

So, in order to understand it better, I built it. This may not have been wise, and their were a number of decidedly non-wise decisions in this project (I’ll get to those).

For your enjoyment, and my own, I will be posting here, as regularly as I can manage, until this blog has caught up with me in reality.

-Anorak