Tumgik
#i have to calculate sun angle at each time of day according to building orientation
outerloop · 6 years
Text
Anatomy of a Falcon
youtube
We recently announced Falcon Age, a game about nurturing a falcon from a baby, bonding with them, and together resisting the forces that colonise your planet. Falcon Age will be out in 2019 for PS4 and PS VR.
We showed off the game at PAX last week, got a great response, especially on the falcon. Let’s do a deep dive of the design of the falcon, animation and rig setup, AI and navigation, feather tech, and raptor sounds.
Falcon Design
Chandana Ekanayake and Darran Hurlbut
Tumblr media
Our falcon design combines multiple raptor types. She is big as a golden eagle, fights like a hawk, has some eagle-hawk resemblance, some owl-like tufts, and falcon tendancies. She’s one of the last of her kind left in our world and we wanted to make her unique visually for the story and also visually stand out during gameplay against the sky and desert like environments.
Tumblr media
One of the early inspirations for Falcon Age came from videos of golden eagles hunting large mountain goats. That led to some research on falconry and the idea of having a falcon as a pet and designing mechanics and gameplay around that core idea. We made a rough prototype early on to test out the ideas. The first time we successfully whistled for the bird in VR and saw the scale change from it approaching from a distance to landing on our hand, we knew we were on to something that could serve as the core of a unique game.  
Animation and Rig
Aung Zaw Oo
Tumblr media
FALCON FEET TRACKING
There are lots of animation options out there, but none of them would easily solve our specific falcon feet tracking needs. Inverse kinematic setups, root motion and other complex plugins could do the job if we had a bigger team and more time to dedicate to it. We wanted a more predictable outcome so we went with a multiple pose based solution made in 3dsmax.  
However, the biggest reason for not using IK, is that this is the best way I could come up within a couple of days. We were building the prototype so fast back at the beginning of the project that we didn’t have time to look at what other solutions are available. This is the most reliable and least ugly way I found and we’ve stuck with it since. If it's not broken, don’t fix it.
Here is how I imagined the bird claws blending IRL. The ball is the fist that is attached to the VR motion controls.There are limits to this method. The claws needs to be able to wrap around a fair chunk of the fist and the fist pose needs to be as spherical as possible.
Tumblr media Tumblr media
Note that head and legs are siblings of the pelvis. This makes the bone masking and making separate blend trees easier. Ignore the word ‘eagle’ in the naming. That was just a temp asset name before we figured out the bird design.
Tumblr media
Short version of how its done; the fist is a ball and the bird’s feet rotate around the ball using 30 blend poses and shuffle animation to get the feet back to center when the ball(motion hand) has rotated too far.
30 Blend Poses on a ball
Tumblr media
A shuffle animation let feet recenter
Tumblr media
And the the blends start again after that quick shuffle animation from the new rotation of the hand. According to our programmer Justin, he is doing some regular old quaternion and linear algebra math. And I’m using 3 float values that he’s giving me and feeding them into those anim blend states.
For baby bird, the 2nd knuckle on the index finger is treated like a ball. 
Tumblr media
The one edge case where the ball concept doesn’t work is when the glove is pointed directly down. Pictured below.
Tumblr media
We had several ways we could’ve dealt with that case. One solution was to have a collider on the forearm part of the glove and have the bird fly away if bird’s collision intersects with it. Ultimately we decided to let it be as is. It’s more player friendly that way since it lets you scratch your left hip while in VR without having the bird leave you. Also most people would never have their hands positioned that way in normal play. 
Unless they’re playing in a headstand for some reason. All kinds of animation features would look wrong or broken in a headstand.
Tumblr media
FALCON HEAD TRACKING
Short version of how its done; the head (bone_Head) is a direct child of the highest object in the bird skeletal hierarchy ( bone_Root ).
Bone_Root’s position(not rotation) follows the position of the motion controller and bone_Head counters that motion. Basically a 2-object hierarchy where a positional blend is used to counter motion of the parent object to keep the child object in same global position. The rest of the bird body uses a blend of 27 poses to try its best to keep the bird looking natural.
Tumblr media
With the size of the adult bird we have, a 12 cm translation in all axis(24x24x24 cube) seemed ideal for getting the stabilizer effect without stretching the neck too much. The head will also move at the edge of that range and when the motion hand stops moving, that new position is now the new center and another 24cm cube is formed there.  Math wise, headlock is mostly just a vector transform with a lot of extra 'fluff' for limiting speed, transitioning in and out, and moving the lock point when it gets too far from the body but the bird is still in the area.
Tumblr media
Bird Navigation and AI
Justin LaLone
BIRD BOREDOM
For the most part, the falcon obeys Ara’s commands and follows her around.  If you stand around long enough in one area while the bird is just circling or if you launch her with no orders, she will start looking for something else in the area to do - usually hunting or landing on a point of interest.  She will also take some initiative when perched on Ara if anything else tries to grab her (she’s possessive like that), and likes to help lead Ara to the next hole in lightning golf.
SUN BLINDING PREY
Some of the prey, such as the rabbits, are very skittish and as soon as they notice a falcon diving towards them they will take off for the nearest bolthole.  They have a more difficult time seeing Ara’s bird if she approaches with the sun behind her, so paying attention to where the light is coming from and sending the bird from that direction can make catching prey easier and more reliable.  On the other hand, simply diving from higher up can be good too, as the bird can pick up more speed before being noticed, giving her prey less time to dodge out of the way.
Tumblr media
Coming in fast and and from the sun, for a guaranteed hit.
FALCON 3D NAVIGATION
Getting a flying animal to reliably traverse a 3D space in a somewhat natural looking way isn’t something you typically find out of the box in a game engine.  We have roughly three levels of bird-navigation logic going on to get the bird from point A to point B without running into too many things or getting stuck in a corner.
Tumblr media
For high-level navigation to find its way through the world, we build a 3D navigation graph and use A* to find a path.  What’s probably somewhat unique in our implementation is that we are using the fairly new Unity job system to do all our A* pathfinding, giving us fast searches that stay off the main thread, allowing more time for other AI, physics, and more stuff in general.  Most of the graph is generated automatically, with manually placed connections for flying through narrow gaps like windows that are small or require an approach from a good angle.
Tumblr media
The purple line is a rough path for it to follow to get around the big rocks in between where the falcon started and where Ara is standing.  The bird doesn’t try to follow this line very closely; it would be trying to make some pretty strange and sharp turns if it tried, so as soon as it has a clear shot to the next part of the path it heads there instead.
Tumblr media
Sometimes smaller objects or moving objects can get in the way.  The falcon looks ahead and goes over or around these objects.  This rock is actually just big enough that it would normally navigate around it with A*, but I forced it to “forget” about that for now.  Here, it’s turning left to go around the rock - the red lines show where it has been looking for the past few frames.  It usually won’t try to go under things in this way, but the A* navigation can direct it to go under arches or walkways.
The last level of bird flight logic is the actual maneuvering logic, or how the bird decides how fast it wants to go, how much to ascend or descend, how quickly to turn, and how it applies physics accelerations, limited by what it is allowed to do, to get there.  This feeds into the animation system telling it how hard the bird is working, what sort of pose it should be in, if it should be banking, etc.  The object avoidance is tied in somewhat strongly with this, but all the A* navigation is completely separate.  It is also a big pile of math and logic.
Feathers and Rendering
Ben Golus
The small body feathers, or contour feathers, on our birds flutter in the wind, and react to the player’s hands brushing against them to give a greater sense of tactile interactivity. The way this was done for the PAX demo is a bit of a hack which I hope to replace before we ship. (This of course means it’s the solution that will ship with the game.) The short description is each small feather on the bird is a treated like many grass or vegetation shaders. Several overlapping sine waves are used to calculate some simple noise used to flutter the feathers and give them some life. Their timing is offset by a random value per feather stored in the vertex color, and the flutter movement is scaled also using the vertex color. This means the base of the feathers don’t move, but the tips do. It also means longer feathers move more than shorter ones.
Tumblr media
Unlike most grass shaders, we need the feathers to not move in random directions, so we can’t use world or local space directions. Plus this is on a skinned mesh which makes the direction even more dynamic. Instead I use a combination of the feather’s vertex normal and tangent so the feathers flutter in and out and side to side relative to their orientation. This isn’t strictly accurate, but for small movements like this it won’t be obviously wrong.
To handle hand interactions, the player’s hand has a script which tracks the bones and creates a list of capsules that follow the shape of each finger, and a sphere for the palm. If the hand is in range, the vertex shader iterates over the list of capsules to find closest distance to one and softly scales down the flutter if a capsule one is overlapping it. The feathers are also squished down towards the body. The capsules are oversized as the overlapping tests are soft, so this isn’t an instant on-off, but a gradual change. It’s roughly tuned so that once the visible finger is touching the feather it has stopped moving entirely and will push down.
Tumblr media
Here’s an early test of this system in action. You can see how the feathers react to the sphere before it actually touches it, but the interaction is still convincing.
Tumblr media Tumblr media
For the final release of the game I’d like to move to a geometry shader or compute shader approach which would solve some of the issues the effect currently has when only one vertex of a feather is being overlapped, and the fact the feathers light normals don’t change when being touched.
FALCON DAMAGE FEEDBACK
We needed some way to show when the bird is hurt, and we wanted to avoid using a health bar or similar mechanic as much as possible. Animation is used to make the bird look tired, and in pain, but we still didn’t find that it was clear enough to users that she had taken damage. We decided we wanted her to look physically damaged with blood and frayed feathers to really strongly communicate her state. The obvious answer was to do a material swap. However we also wanted to show a gradual increase in damage rather than a hard on / off, and did not want to have to have a lot of different maps. There was also the issue that most feathers shared the same UVs, which meant blood spots would be repeated all over the bird.
The solution we ended up with was done in two parts. First was feather damage and fraying. The alpha channel of each feather is setup in a special way so that both an undamaged and damaged version exist in the alpha at different opacities. The feathers are using alpha test cutout (actually alpha to coverage) at 50% opacity when at normal health, and 25% opacity when damaged to switch between the two states.
Tumblr media
For blood splatter the bird has a second UV for the blood texture so we don’t have to reuse the original feather texture UVs, and then we blend in the blood on top of the base texture. The result is we only need one base texture set, and one blood splatter texture set for the bird and we can get variable damage effects on the bird.
Tumblr media Tumblr media Tumblr media
Raptor Sounds
Rob Pearsall
Tumblr media
The bird wasn’t designed to be different - futuristic or magical - from any bird in our world, just an amalgam of several flying raptors (except for wearing hats); so, it didn’t make any sense to create a voice for it that might sound ‘cinematically awesome’ - it just had to work and be believable.
That said, I did have the choice of “borrowing” the calls of any raptor I thought would communicate to the player the various moods, feelings, and responses of the bird.  So, I listened to the sounds that raptors make; and to my surprise, the biggest, most impressive bird - the eagle - was absolutely the worst sounding predator of them all.  First place for “don’t use this”.
The hawk is always a great choice.  Everybody loves the screech of a hawk.  I used to think that there was only one good recording of a hawk screech and every sound designer owned it and that’s why all hawks in all shows and movies sound the same.  Not true.  It turns out, all hawks sound the same.  Not much variation at all.  Now, don’t get me wrong, it sounds awesome, so yea… we’ve got that sound on our bird too.  But that’s not all.
The best thing I had going for me was that I didn’t have to limit our falcon voice to one specific kind of falcon; and there are many kinds.  Because of this, I could liberally choose any sound any falcon produces that makes sense as a kind of emotional statement from the bird.  
Conveniently, the emotions were limited; I name them as statements from the bird:
All is calm, all is well
I hear you call me
I’m attacking
I’m hurt, but I’m still flying
That hurts
Getting a recording of a raptor that’s annoyed is really easy; show up with a bunch of recording gear, get into it’s space, and it’s already annoyed.  So, there’s a lot of material of raptors sounding negative and mad.  This works for ‘pain’.  The hawk’s sounds work for flying responses and attack calls.  The “all is calm” sounds were the difficult ones.  There were several chirps that worked, but then I had to edit a lot of different kind of calls to get partial, short squawks that fit with the chirps, and it worked.
Keeping track of the bird sonically while in game… well, that’s another story for later.
Thank you!
Tumblr media
Thanks for reading. For more info and latest updates follow @outerloopgames
15K notes · View notes