Performance Problems in Kenshi

Are Performance Issues All Because of OGRE?

Everybody says it a lot: Ogre is an old engine and Kenshi runs at a snail’s pace because of it.

But that’s only half the story.

Yes, Ogre is single-threaded, which slows down the performance pipeline. However, performance comes down to more than an engine. Assets in any game development pipeline need to be optimised – and many of Kenshi’s assets are far heavier than they need to be.

The truth is, a lot of the performance problems can be improved, and LitA combines the performance hacks of Kenshi: Remastered, ReKenshi with a better asset pipeline. Existing assets are optimised by ~40% and the whole material pipeline is designed with strict targets in mind. In total, all assets across the game come in at under 4GB – including the heightmap; terrain materials; clothing; weapons; and races – by making more directed decisions.

That means that a player running a high-end graphics card could have everything loaded at once.

No, that doesn’t mean LoFi made bad decisions, only that they could have done things differently. After all, we’re looking at a completed project in post and figuring out where its weaknesses are – and planning around them.

How We’re Optimising for Performance

LitA uses a mix of scratch-made and vanilla assets. Fundamentally, we’ve optimised them in two ways. Firstly, are polycounts, and secondly, are the materials used in rendering.

On top of those optimisations are a mixture of rendering improvements thanks to Kenshi: Remastered, and in-engine improvements that relate to level design, AI optimisation, and a handful of miscellaneous optimisations.

No, we can’t make Kenshi perform like it’s running on a new engine. But we can squeeze as much performance as possible out of it.

Asset Optimisation

Polycounts refer to the numbere of polygons in an asset. While GPUs improve over time, making polycounts less important overall, there’s still always going to be a hard limit to what an engine can display (and don’t say “Nanite” or “UE5”).

Put simply, we’re working with stricter polygon targets than are used in vanilla.

For instance, the polycount of a set of Holy Nation chest plate is around 6,500 tris. The retopologised mesh used in LitA comes to 2,500 and looks virtually identical. On average, the repurposed vanilla meshes are 40-50% more optimised than those used in vanilla, and new meshes aim for the same targets.

Buildings and level geometry adhere to the same philosophy: Lower polygon counts as much as possible.

Better Material Design

Level geometry – buildings, props, walkways, and features – use a lot of textures. In total, the textures across all buildings used in-game come to between ~1.5GB and ~2.3GB (depending how you count).

LitA’s materials use a different design philosophy, focusing on more trimsheets and seamless materials over individually textured assets.

This is a benefit for two reasons. Firstly, we reduce the total VRAM load of materials to under 1GB; and secondly, we improve the visual fidelity of large assets by tiling the materials more.

What does this mean?

Here’s a texture for a level IV wall from the vanilla game. It’s a 4K asset, meaning the base texture plus normal map come to 42MB:

The problem with this is that huge surface areas – the wall itself – use relatively small parts of the texture map. The second problem is that relatively niche assets use a lot of VRAM – a level IV wall; its gate; and a tower use a total of 6 4K material atlases, totalling 128MB alone.

There simply aren’t enough pixels to render the wall in high fidelity. The end result is a wall that looks like this:

Notice how blocky and pixelated the walls look up-close.

By switching to a material-based workflow, we can tile the textures while upscaling many of the base materials – without losing any performance. This, combined with a handful of other tricks (more modern compression techniques and selective downscaling of non-essential materials, like metalness and normal maps), means that everything looks as good up-close as it does from a distance.

No blocky textures!

The environmental assets that are textured individually are either niche, location-based assets (like town signs) or small enough to warrant the textures (like faction banners). Additional details and “greebles” are handled via shared trimsheets, like these:

They’re rendered in high quality, and give a lot of details to work with without sacrificing performance.

Heightmap Optimisation

Bfrizz, the mad genius behind ReKenshi, wrote a new lossless compression algorithm for Kenshi’s heightmap, reducing its size by ~300MB. The heightmap is stored in memory permanently and the compressed version doesn’t lose any details.

This won’t have an in-engine effect, but will significantly improve loading times for non-SSD users. SSD users may notice a minor benefit.

Miscellaneous ReKenshi Hacks

Bfrizz is split between pulling more performance out of Ogre and integrating a scripting API – and we’re happy to wait while he experiments with performance hacks.

One such hack is crunch compression. It’s an addition compression method that can boost loading times, though it’s currently still being tested for stability and performance boosts. Currently, it’s in a working state. Assuming all goes well, it’ll either be integrated into LitA base or LitA: Hot Potato Edition™ (below).

Miscellaneous Optimisations

There are a lot of small-time tweaks made that add up to small gains in performance. All clothing items use pre-rendered icons instead of relying on a virtual photobox; siege and mass-battle AI is optimised for faster decision-making; and most mass battles are designed around select locations that avoid GPU-heavy particle and weather effects.

The largest, “hero” type assets, while polygon-heavy, are hand-placed at locations where they won’t make an impact. All miscellaneous terrain features and foliage assets are as optimised by more than 50% when compared with vanilla; and they’re used more selectively to retain the look and feel while avoiding an over-reliance on them.

The world has a more uniform look, too. Yes, there are all sorts of biomes and environments – from frozen tundras to scorching deserts to mysterious shadowlands – but environmental materials are shared more frequently without sudden, jarring transitions between biomes. The result is in the lower overheads when transitioning between biomes.

Potato Optimisation

Let’s face it: Some people run Kenshi on a potato.

What does that mean for us?

Well, in addition to all that we’ve talked about, we’re bundling LitA with the LitA: Hot Potato Edition™ addon. It’s an optional addon designed for low-end users that should offer substantial performance gains at the cost of some of the visuals.

This addon may come in different flavors, depending on popular demand. However, the basic edition will do the following:

  • Render all materials at half resolution. This cuts their size on disk down by 75% (meaning less stress on VRAM). Plus, rendering these materials at low resolution instead of compressing them in a photo editor yields far better results.
  • Crunch compression may be used on top if it yields enough performance benefits (and assuming we don’t bundle it with the base LitA edition).
  • Optimise level geometry. Cutting down on superfluous foliage and level props will remove a lot of superfluous detail. Props like furniture and greebles that are tossed around to liven a place up – we’ll remove a select amount of these that preserve the look and feel of locations while helping with performance.
  • Optimise sieges and mass battles. To cut down on the number of NPCs who clog up your GPU during mass battles, Potato Edition™ will reduce the overall NPC count by around 30%. At the same time, the remaining inhabitants of the world will be upscaled in their abilities to account for the loss.
  • Optimise base meshes. A lot of the meshes used for armour, characters, and animals can be optimised by around 30-50% at some fidelity loss. This is a tradeoff that will reduce polycounts by a substantial amount at the cost of some minor clipping and detailing issues.
  • Rendering hacks (pending). Kindrad is planning on implementing a select number of hacks to improve Kenshi’s rendering pipeline further. It’s an ongoing process – so the amount of performance gained in initial tests will determine the extent to which the hacks are implemented. The Remastered page will go into more detail when we know more.

How much we push the fidelity-optimisation tradeoff will depend heavily on feedback and playtesting.

Lore of a Lost World #1: The Fairisle Dynasty

The Fairisle?

Control damn near every trading post from Varlance to Pilgrim’s Passage. Them tribals, they know to steer well clear and only handle for scraps when their huntin’ comes up scant.

The Dynasty owns everything ’round here. It’s not just the water. They own the food, the traders, the caravans, the soldiers, the guns. Nobody gets in their way. Not anymore. Safer to put vendettas to bed. Not a damn thing ’round here they don’t lay claim to, my people included. Sure, there were those who resisted.

Once.

And you want to know what happened to them? They fell. Every last one. Not to war, not on the battlefield. Poor souls at the mercy of a ticking clock. All the Fairisle had to do was turn off the taps. A tear to salt the dust, as they say, but I have people to watch over. The Fairisle do as takes their fancy and there ain’t nobody left who’s stupid enough to tell them differentBut they’re a big fish in a dry lake. Long as we pay our dues, we don’t get trouble from them. Some tribute here, free room and board there. The odd troublemakin’ ratel to man the ramparts on Sha’lin Spring.

You want to run off, join the Rebels, be a big damn hero?

Leave us out of it.

– Unknown village elder

Water isn’t always scarce across the wasteland.

But clean water is.

Powerful and respected across the continent, the Fairisle Dynasty are the sole survivors of the Water Wars. In the wake of a devastating conflict, their hegemony in the northern biosphere solidified through a combination of ruthless diplomacy and tactical warfare – by the end of it, the Dynasty’s enemies were routed, destroyed, or subsumed.

Now, they rule over their quasi-subjects with an iron fist. Both independent settlements and those firmly under their purview rely on the Dynasty for the most valuable resource in an arid wasteland, and the Dynasty knows it. Every samurai in the Dynasty’s standing army is trained and equipped to the highest of standards.

On paper, their armies are without equal.

Empress Daisumi

Ruling from the near-impenetrable fortress of Sha’lin Spring, the ever-paranoid Empress Daisumi is rarely seen by her lessers without a company of elite Yodoka at her side. Daisumi is so distrusting of others, in fact, that few among even the ruling noble class have ever consulted with her directly, yet alone laid eyes on her in person.

Built around one of the last remaining viable springs in the wasteland, her star fortress is manned by an army of hand-picked samurai and stocked well enough to outlast a siege for months, if not years on end.

It is a shining beacon of the Dynasty’s power, and a stark juxtaposition of the wealth disparity plaguing the nation.

For no paranoid and impulsive autarch can secure the longevity of their rule.

Unlike her level-headed and beloved father, Daisumi came into power at a very young age following a dispute with older siblings and cousins. A spat of summary executions took place behind closed doors, a host of prominent field officers were “promoted” to the ranks of the nobility, and Daisumi’s power was absolute.

Yet it did not take long for dissent among the peasantry to gain traction.

[…] Once upon a black moon there were none who opposed our might. But the sands of time never rest. I cannot abide another war council that is nothing more than a thinly veiled drinking contest. The Empress and her cronies would bury their heads in the sand and toast to another “successful” harvest while the fields that grow the wheat in their bellies burn in the fires of war.

A dynasty of fools.

To the south, the Bazaar Masters wait, and trade, and sign treatises, and smile, and bide their time and build up their armies. The crumbling Western Wall barely contains the bloodthirsty hordes of the Third Dominion. Those barbaric Moonrend fanatics enroach on our frontier from the east. Even the Dunelords grow bold and strong. There was a time I wouldn’t lose a man in a pissing contest over the Weranga, yet now it would take two hundred to meet those miscreants in the field.

Once upon a black moon, the Tribal savages feared the mere silhouette of a Fairisle patrol on the horizon. Now they do not so much as blink at a dozen tenfolds of men or the thunder of their guns. And here I find myself, again forced to send another generation to dye the sands.

I grow weary.

– Shogun Odaa

Under the Empress’ reign, rebellion has sprung up on the frontiers between the “civilised” and “uncivilised” world. That drought and crop failure are common from sea to barren sea is the way of the world – yet maintaining open trade and keeping the populace in bread and water has proven near impossible thanks to constant raiding and pillaging.

And around a waning power structure, the vultures circle patiently.

What’s Taking So Long?

As most people who’ve been following LitA for a while know, development is dragging. It’s been in a murky status of “in development” and “in super secret closed beta” for a long time.

And yeah, arguably it was stuck in development hell for a while.

Progress To Date

There’s been a wealth of progression in everything to date. Everything from assets to animation to procedural dialogue, world terrain, and quests is in a late stage of completion. In other words, most things are somewhere between 60% and 90% done.

The key is iteration. Systems have been iterated on again and again to improve them and keep improving them. Sometimes it’s because of a critical bug. Sometimes it has been a “back to the drawing board” moment where I’ve looked at everything in a grander context and tried to piece it together differently.

The more you read these posts, the more you’ll understand why.

To date, progress in numbers looks like this:

  • 75+ ambient life animations
  • 15 “special” animations
  • 225,000+ words of dialogue*
  • 60 combat animations
  • 100+ armour pieces
  • 2 new weapon categories
  • 50+ melee weapons
  • 13 musket weapons
  • 50+ new items
  • 75+ new icons
  • 100+ new books
  • 200+ unique bounty characters with posters
  • 250+ unique adversaries
  • 125+ minor buildings
  • 50+ major buildings
  • 100+ PBR materials
  • 45 new factions
  • 20 major dynamic questlines
  • 100+ minor dynamic quests
  • 100s of randomised events
  • 1,500+ town overrides
  • A whole new world to explore
  • In other words, a metric fuckton of new content

*This is an estimate based on averages. Most of the procedural dialogue is broken down into individual phrases and sentence fragments, with some events (e.g. “Come at me, bro!”) consisting of more than 10,000 words each. I average a few dozen long & short events and make estimates of the total amount of dialogue written based on that, cross-referenced with the total number of hours spent writing.

The Big Stuff Left

The most important “big thing” to finish is the new world.

It’s in a “completed state”. All that’s left are minor tweaks and touches – as well as shunting a few things around and running some weathering simulations again. It’s efficient and striking with massive variety in biomes and terrain layout.

The most important step left is optimising and smoothing out the terrain in places.

The above terrain is an example.

It looks great, but it’s too bumpy for the navmesh to handle. As-is, it’s almost acceptable. You can walk around and navigate fine, but there are still too many holes in the navmesh.

The second most important step is finishing a lot of things that are around 80% done. Weapons, armours, buildings, animations. The majority is completed – again, it’s about tweaks and fixes. Ultimately, it’s tedious to do and only a matter of time.

Putting it Together

Once assets are largely complete, everything needs to be put together again. Mostly, that means systems, reputation, quests, and adversary logic that was taken apart prior to designing a new world.

The thing about game design is… Everything’s looks crap until it doesn’t.

Factions and lore are an ongoing process, but there are multiple writers and worldbuilders behind that. They’re great and having a team of people with different perspectives has helped massively in making the lore of the new world layered and complex.

Because the narrative structures – quests, reputation, dialogue – were designed from the ground-up to be modular, migrating them to the new world isn’t as daunting as it sounds. The first big dynamic questline, a three-tiered beast that scales up from minor conflicts to engulf an entire region of the map, can just be slotted in with only a few dozen dialogue tweaks and reference changes. Unofficially titled The Scarlet Rebellion, that quest centred around the Rebels in their struggle against tyranny and served as a blueprint for many other questlines: What works, what doesn’t, and how best to leave choice and agency in the player’s hands.

The Testing Phase

You know what a beta is. With LitA, it’s split into three phases.

The First Phase

Phase I involves a lot of boring tests. That includes endlessly triggering dialogue events and asinine activities like opening and closing your inventory a hundred times before importing and doing it again.

It’s boring as hell, but necessary to keep LitA from breaking the game or encountering critical bugs later on. Most of it I’ve already handled myself – but several dozen new tests will need to be run when stuff is put together.

The Second Phase

Phase II testing is testing everything together in “dev mode”. It’s mostly around the big quests and unfolding global events like faction wars. It means stripping away fluff and complexity and testing in a linear fashion.

For instance, a quest spanning a huge region is pared down. Complex dialogue is replaced with simple choices, “special” NPCs to hunt down and kill or save stand around at pre-determined points (and die in a single hit). Sieges and wars are minor battles that resolve in under a minute.

The point of this phase isn’t glamorous. Mostly, it’s about making sure I haven’t buggered something up in a sea of if/else statements. Explore every possible pathway without needing to sit down for a dozen hours at a time.

The Final Phase

This is the open beta phase. The third testing phase is where LitA opens up and full features are available for testing.

It’s gonna be a wild time.

Prognosis

How long’s left on the docket until release?

As always, it depends.

One of the more frustrating elements of a project like this is that the systems are built on top of each other. I can’t finish thing A until thing B is done, and I can’t release until (virtually) everything is done.

I have a history of scrapping releases for various reasons, often due to iterating on ideas and re-evaluating with a new perspective. Sometimes that’s because of a critical bug. Once, it was because of a long-term memory leak issue.

The good news is that time is over.

Now I’m ploughing through. Features are locked-in. I’ve got a long list of things to finish, and in general I estimate by hours.

At present, estimates are around 800 to 1,000 hours left until it’s finished. That’s finishing dialogue, terrain, quests, gear, buildings, reputation, adversaries, and more. The 200-hour buffer is mostly around designing the new towns. Many exist on paper (or in the worldbuilding channel) and I do have volunteers willing to handle some of the in-game town design.

I work fast. It’s a reasonable estimate that adds buffers to everything. In the end, the number of hours I can put in each month depends on other stuff going on in my life. There are no guarantees and I won’t make any, because I’m not going to rush a release.

Maybe it’ll be half a year. Maybe it’ll be a full year.

This website will keep you in the know.

Want to Sign Up For Beta Testing?

Around 50 people are on the beta waiting list and you can sign up here.

Thinking of Getting Involved?

We always need new ideas for adversaries and unique bounties, and you can submit ideas here.

We have room for more 3D artists and writers on the team. If you’re interested, head over here. At some point, we may bring some level designers on, as well.