Wednesday, 19 February 2014

Folk Tale Dev Blog 20

We're making solid progress in the 0.2.x release cycle, and today we're able to take an early look at two major improvements in the pipeline. We have a working Player breathing life into custom maps designed in the Editor, and Character Studio where we can experiment with character randomization.

Sandbox Player

One of the key requirements for Patch 0.3 is the ability to play a custom map designed by us in the Editor. Internally we're now able to run Sandbox maps and test dynamics including character movement and construction. Testing pathfinding is particularly important as we've deprecated the memory inefficient grid based graph system in the Tutorial and developed a faster Tile-Based Navmesh system that supports updating during gameplay.

Developing a new pathfinding solution helps reduce the overall game footprint in addressable system memory ( reduced probability of a memory related crashes on marginal systems ), while making path calculations faster ( better frame rate ).

The blog video demonstrates a test case of running one group of villagers over a bridge while the other group run under it. This wasn't possible in the Tutorial ( anyone notice the rubble blocks in the Old Forge blocking access to the ramparts above the portcullis entrance? ), but for Sandbox it opens up lots of design options.

Character Studio

One of the frequent pieces of feedback we received following launch ( particularly in Let's Play videos ) concerned all the villagers looking like drones. Given that a major feature of Folk Tale is the detail of the lives of your Villagers and the adventures they become involved with, it's important that we give them an identity.

In the Sandbox Vision Presentation I explained why it wasn't possible to achieve full RPG level of visual customization due to memory constraints ( GPU texture memory and overall system memory ). Instead, we set out to give each villager a unique face, and show their currently equipped hand items ( tools and weapons ). In Dev Blog 10 I highlighted early development on facial customization, and since then we've expanded the customization system into something that is usable and will be included in Patch 0.3.

There's a lot more going on under the hood of Character Studio than first meets the eye, specifically to address technical objectives:

Minimal Memory Footprint

We've designed the character system using minimal base geometry and a single hair/skin texture to keep memory requirements down. We have one universal skeleton for all humans, two master head models - male and female - and a number of uniforms. We have a range of hair styles, eye brows, and facial hair, that we'll continue to add to throughout development to add more variety. All the geometry is combined at runtime into a single skinned mesh with just two materials: one for the uniform and one for the skin and hair, both of which are color tinted separately in the shader.


The more bones included in the skeleton the longer it takes the CPU to calculate the position of each vertex in each frame of animation before sending to the GPU, and that means lower frame rates. To achieve both a unique appearance AND good performance, we're baking appearances and then removing the influence of certain bones ( e.g. facial bones, 2nd-4th fingers ), reducing the bone count down from 140+ to around 60. This wasn't something we did in the Tutorial, and should achieve a performance boost.

Baking appearances does mean character faces won't be animated during normal gameplay, but will be during cinematics where facial animation can add a lot of emotion. We have implemented bake quality, so it might be possible on higher specification systems to enable facial animations during gameplay. It's something we'll be exploring after Patch 0.3 but is not something we're committing to at this stage.

Combining multiple meshes ( head, hair, facial hair, eye brows, uniform, exposed skin ), optimizing out bones and baking into one skinned mesh at runtime needs to be extremely fast considering how many characters we have and the possibility for changing weapons and tools, so we've invested time up front in optimizing the process. From very early proof of concept code taking 500ms per bake, within a matter of hours it was reduced to under 2ms. That means we can bake several characters at once ( for example when new villagers are created ) without significant impact on frame rate. In reality this only happens a few times every minute, or when hand-held gear is swapped out, so we are well within acceptable performance targets.

Universal Skeleton

Having a universal skeleton for all human characters means we can play any human animation on any human character. For example we can have men walking like women, but that's not the real use. The main strength lies in how we implement weapons. We're creating combat animations around weapon types: one-handed, two-handed, and dual wield. A pitch fork and halberd are somewhat similar in that they are held with two hands and look perfectly acceptable using the same combat animations. A sword and mace are also similar and can use the same one-handed combat animations.

In a game with lots of buildings, lots of characters, and lots of weapons, there's lots of creativity and trickery required in striking a balance between the quantity of assets and achieving an acceptable quality and accuracy of animations. The hard constraint of memory means eventually you hit limits, and you can't increase one without reducing the other.

While we only need randomization, baking and bone optimizations working for Patch 0.3, beyond that there's lots of potential for Character Studio. Here are just a few low-priority ideas we'll be considering at a later date:

  • sharing configuration text strings with others in the community forum to recreate characters;
  • naming and adding personality traits for inclusion in your games ( e.g. if you always want Henry The Coward to be one of your villagers );
  • uploading NPCs to Steam Workshop.

Art Assets - Characters

We're keeping up character production momentum with the addition of the male and female Peasant, Woodcutter and Baker. They Peasant and Woodcutter follow the visual style established in the Tutorial, but remade to fit the new customization system while standardizing the look of the villagers.

Art Assets - Buildings

Three more sandbox-spec buildings are finished ready for inclusion in the next patch: Stonecutter Lodge, Storehouse and Tavern. With the Player advancing at pace, the next step is to enable Resources ( Logging Camp, Iron Mine, Stone Quarry ) and early stage sandbox gameplay ( resource collection and processing ).

What's In Production?

Feature Icon