29.04.2024

The history of porting Kingdom Come: Deliverance to the Switch case from Saber Interactive

In March 2024, Kingdom Come: Deliverance was released on the Nintendo Switch. The original version of this historical action role-playing game was released back in 2018. Zhanna Goranskaya, Director of Business Development at Saber Interactive in the CIS and Eastern Europe, told in her column for App2Top about how the work on the port was going on.

Zhanna Goranskaya

In terms of complexity and scale, the work on adapting Kingdom Come: Deliverance for Switch can be compared to porting The Witcher 3: Wild Hunt, which we did in 2018-2019.

Both projects are role—playing games with large-scale open spaces, detailed cities, complex architecture, and, of course, a large number of NPCs.

As Thomas Morgan successfully noted in the analysis of the port on Digital Foundry, transferring Kingdom Come: Deliverance to Switch is one of the cases of "impossible ports", which, by the way, included The Witcher 3.

Let me remind you that the Switch was built on the Tegra X1 system, originally developed for mobile devices based on ARM processors. The system will be 10 years old next year.

As for Kingdom Come: Deliverance, the game was not only intended for x86 processors, which have their own set of instructions and their own microarchitecture, but for years after its release it was considered a very resource-intensive solution.

Of course, this was not the key challenge. Porting from x86 to ARM is now a common practice. It's just important to understand first of all the initial resource intensity of the game and its scale.

The advantage for us was that Kingdom Come: Deliverance was developed on CryEngine 3. By the time we started work, we had already become familiar with this engine. In 2021, we released (including under Switch) Crysis Remastered Trilogy.

It was after the trilogy — at the beginning of 2022 — that we took up the transfer of Kingdom Come: Deliverance.

Two teams were responsible for the port:

  • our Swedish studio has done most of the tasks of adapting the engine to Switch;
  • The division that we call Saber Core was directly responsible for porting the game itself. It brought the game to release.

The port was based on two versions of the game at once: the art was used from the Xbox version, and the code and settings were used from the PC version.

For the first six months of work, the pipeline looks something like this:

  1. Analyze all assets and technologies used.
  2. Make a specific work plan for their optimization.
  3. To ensure the launch of the build on the Switch.
  4. To ensure that the main character at least moves within the framework of the build.

We managed to cope with these tasks more or less quickly. It turned out to be the most time-consuming to transfer the CryEngine 3 version adapted by Warhorse Studios to Switch. After that, it turned out to be enough to squeeze all the data and optimize assets.

It would seem that everything is there, the build is running, you can even try to play it. But in fact, it was only the beginning. The real front of work, implying a battle for productivity, getting rid of numerous visual artifacts and bugs, was just looming ahead.

Yes, it was difficult to play not only because of FPS in a couple of frames and constant errors. At that moment, the launch of Kingdom Come: Deliverance constantly led to memory leaks, which led to crashes.

The second major stage of work on the port began in August 2022, when Saber Core began to fix problem areas.

This very painstaking work went something like this:

  • at first, QA specialists went through the game step by step, noting the places where the frame rate drops;
  • then the engineers checked these places and came up with what could be carefully changed so as not to spoil the scene.

It was at this stage, for example, to reduce the load on the central processing unit (CPU), some of the calculations were transferred to the graphics processor (GPU).

As a result, the calculation of the swinging of blades of grass in the wind, facial expressions, swaying clothes – all these parallel operations were transferred from the CPU to the GPU.

The next global challenge was the problem of optimizing visible and non–visible objects - something called Occlusion culling.

Imagine that your character is standing on a city street near a stone wall. If he looks at the wall, then you won't see anything but the wall. But the video card will continue to draw what is behind the wall, count buildings, other characters and objects.

This is a big problem for all platforms, including PCs and consoles of the latest generation. The same applies to Switch, for which extra calculations are an unacceptable luxury. Therefore, if possible, the new version of the game began to cut off all invisible parts much more efficiently.

One of the most telling examples is the story of the sheep. Kingdom Come: Deliverance uses a very high-quality physics simulation. For example, when you see a sheep running across the grass, the game does colossal calculations to correctly simulate the movement of the grass, where each hoof will fall.

There are 5,000 computing operations per sheep's foot. Multiply by four legs – we get 20 thousand operations. Now imagine that your hero meets a flock of sheep…

Therefore, in order to increase productivity, we have reduced the number of such operations. Relatively speaking, instead of 5,000 operations for the calculation, one began to remain.

But this led to a result that we could not have predicted in any way. After the reduction of operations, it suddenly became clear that the horses' legs began to fall into the terrain.

In the end, I had to fix it manually: look at each scene separately, where you can change the number of operations, and where not.

Another serious problem was the correct display of clothing and armor. The game has an amazing armor system, close to historical realities. A shirt, a shoulder strap, chain mail, metal bracers and greaves – all this has its own geometry and is calculated separately in order to be displayed correctly.

These calculations are processed in real time, since the armor can be removed from a dead enemy, stolen or put on at any time.

Of course, it was possible to simplify geometry, but this could break the physics calculation system: when moving, the armor would stop looking like real ones and turn into "latex" ones. I had to look for another solution: to do faster calculations and cut off something very filigree that would not affect the geometry.

Of course, in some places it was necessary to go to the trick. For example, all cut scenes in the game are pre-directed, which means we know how everything will go, and we can tweak the quality settings a little bit, for example, trim the rendering range where it won't be noticeable.

And somewhere we went, as they say, head-on: we used low dynamic resolution in complex scenes, additionally reduced the size of textures, reduced drawing ranges, used low-quality shadows and so on, so on.

The most difficult task turned out to be mass scenes: battles, tournaments, any events where more than five characters appear in the frame. The idea to reduce the number of characters was cut off immediately, because then the entertainment would suffer.

We tried to optimize them as much as possible. However, I can't help but note that they remain a bottleneck for game performance. Fortunately, the pace of the game itself is unhurried and the gameplay at such moments does not suffer much because of this.

Overall, it was thanks to this painstaking approach that we managed to achieve acceptable performance almost throughout the game. In open spaces, the frequency of Kingdom Come: Deliverance plus or minus is stable at 30 frames.

We consider this an achievement, given the complexity of the game. Plus, we are very pleased with how stable it turned out to be. From the very beginning, the team optimized memory, ensuring that the game did not crash for at least two and a half hours (standard Switch battery life).

On internal tests, we managed to achieve a 20-hour continuous session. When the console was discharged, it was charged without closing the process, then continued to play. We can say that we squeezed everything we could out of the console's capabilities.

Comments
Write a comment...
Related news