Devlog #29. Game Optimization

Potion Craft: Alchemist Simulator

Potion Craft is an alchemist simulator where you physically interact with your tools and ingredients to brew potions. You're in full control of the whole shop: invent new recipes, attract customers and experiment to your heart's content. Just remember: the whole town is counting on you.

Hello Alchemists! When we add new content to the game, we initially try to do so in a way that performance and resource consumption do not suffer. However, we are constantly coming up with ideas to improve the game systems. Therefore, if we get a moment free from adding new mechanics, we optimize the game. Many players previously commented that the alchemy map was not optimized enough: FPS dropped by 2 times on average if the player looked at the map with maximum distance. The problem was that all of the map object sprites (danger zone bones, swamp waves, parts of map borders, etc.) were rendered separately. In the screenshot below we have highlighted several individual sprites in color. Now imagine that there are tens of thousands of such sprites on the map! [img]{STEAM_CLAN_IMAGE}/39247742/8afbc6c36a76915e7c2bdf572130aa614ebaa0d5.png[/img] To solve this problem, we decided to render the map using a grid of square chunks. All the object sprites from the area where the chunk is located are baked into the texture of each chunk. Now, if all the objects in the chunk are static, the sprite of the chunk is displayed. [img]{STEAM_CLAN_IMAGE}/39247742/cff9cac88f1054e05dd66261f6b41a72a245f206.png[/img] If at least one of the objects plays an animation, the chunk sprite is hidden. And all of its objects are switched to the classic rendering mode – for each object separate sprites are enabled. As a result, the visual part is not affected, but FPS increased by an average of 30%. The previously mentioned significant drop in FPS when moving away from the map is no longer observed. We also paid attention to optimizing the size of sprites in video memory. Previously, many sprites had a lot of empty pixels around the sprite content – they helped us position objects correctly in a space without adjusting the sprite's pivot (this, in particular, greatly simplified our work with generating character appearances). Usually empty pixels in PNG files do not take up much disk space. But the way textures are stored in the video memory is different – there the size of the texture matters regardless of the color of the pixels. So a large number of transparent pixels is bad for performance and resources, especially if they occupy most of the sprite. Also, almost all sprites were not divided by 4 in width or height. This prevented the engine from applying the optimal compression format (DXT5) to them. We created a utility that automatically removes the transparent pixels around the sprite content. This adds/removes them so that the sprite size is now divided by 4, and moves the sprite pivot back to where it was before optimization. As a result, sprites now occupy 2-3 times less video memory and load much faster. [img]{STEAM_CLAN_IMAGE}/39247742/620e61b710238e360e5f51074989e88aaa1fd781.gif[/img] [img]{STEAM_CLAN_IMAGE}/39247742/19b7b3cb9d9322da71b37f1cf005a6ae1a01b1d7.gif[/img] [img]{STEAM_CLAN_IMAGE}/39247742/d719ac9660732585bed3ee1157781e73949b56de.gif[/img] [img]{STEAM_CLAN_IMAGE}/39247742/6c9c8db54198129607b823a6e50e8e95c57b9a57.gif[/img] In short, the results of the optimization are as follows: [list] [*]FPS has become more stable and increased on average by 30% [*]Textures occupy less space in the video memory and are loaded faster [*]We also optimized the game’s loading process, accelerating it by an average of 1.5-2 times [/list] You’ll see all the optimization changes in the upcoming update, which is now in development. These improvements will also be made for the Xbox version of the game and will be included in the releases for the new consoles: PlayStation and Nintendo Switch. We hope that our work will let you have even more fun brewing potions in Potion Craft! Subscribe to our Steam page, and join our Discord so you don't miss the next devlogs! [list] [*] [url=https://twitter.com/potioncraftgame]Twitter[/url] [*] [url=https://www.facebook.com/potioncraftgame]Facebook[/url] [*] [url=https://www.instagram.com/potioncraftgame/]Instagram[/url] [*] [url=https://discord.gg/PotionCraft]Discord[/url] [*] [url=https://www.reddit.com/r/PotionCraft/]Reddit[/url] [*] [url=https://imgur.com/user/potioncraft/posts]Imgur[/url] [*] [url=https://www.youtube.com/@PotionCraftGame]YouTube[/url] [/list]