Techtonica is a first-person factory automation game with a gripping mystery about mining your way out from the depths of an alien planet. Explore bioluminescent caves, mold destructible terrain, construct a massive subterranean factory. Dig your way toward answers & discover the secrets of Calyx.
[img]{STEAM_CLAN_IMAGE}/42118931/ad59f37132525bd3be4030392900e567f01009ec.jpg[/img]
Hello Groundbreakers! I’m Greco and I’ve been working on optimization for Techtonica since I joined the team in January. I'm going to explain some of the optimization work that has been done in previous updates and what’s coming next for 1.0.
One may ask what does optimization mean in practice? Fundamentally, program optimization is about reducing the amount of resources we need to achieve the same result, this includes memory usage, CPU usage and GPU usage. Usually this is achieved through a combination of better algorithms and taking into account the “low level” hardware details, the main constraint in modern PC and console hardware is memory bandwidth, therefore most of the optimization efforts focus on improving the memory layout of the data so that we can maximize the throughput of the core game loops. One great way to learn about this is to study Data Oriented Design, here’s a good video introduction:
[previewyoutube=rX0ItVEVjHc;full][/previewyoutube]
The Unity game engine has some technology built around this concept of DOD, in Techtonica we’re mainly using 2 things: The Burst compiler and the Job System.
Unity has a separate compiler from the built-in .NET Mono compiler and the IL2CPP compiler called Burst, this compiler is built on top of LLVM which tends to produce much better x86-64 code compared to Unity’s Mono JIT compiler, “burstable” C# code also has a lot more constraints, such as no managed memory and containers not being allowed to alias which allow the compiler to emit better code. If you’re a programmer and are interested in learning more about Burst you can watch the following talk:
[previewyoutube=QkM6zEGFhDY;full][/previewyoutube]
The Job System allows us to more easily add multithreading to the game, it works with native memory and integrates easily with Burst, oftentimes Techtonica needs to process X amount of independent items, (usually called “embarrassingly parallel”) so the job system is a perfect fit for this.
Techtonica was initially released as a pure managed Mono C# game, but we’ve been slowly migrating our most data intensive systems to a DOD approach, some of these optimizations include:
[list]
[*] Most of the streaming systems have been rewritten to be more performant (around 5x-10x faster), these include streaming of rendering for plants/environmental objects and visuals streaming for all the machines, this reduces stutters when moving around the map.
[*] Mesh generation for Monorails has been almost entirely rewritten to both be faster and to reduce the amount of memory they occupy, from gigabytes to just a few megabytes.
[*] Streaming textures from disk on Xbox and PS5 to reduce the total amount of memory used and therefore reduce the amount of game crashes caused by out of memory errors.
[*] Overall memory usage for machines has been reduced.
[*] Large rewrite for most of the rendering systems, using an optimized approach for uploading matrix data and performing culling on the GPU.
[*] Deferred lighting has been significantly optimized by using a tiled renderer, this significantly reduces GPU usage.
[*] Reduction of the amount of memory and CPU used by all the plants and environmental objects.
[*] Various optimizations to reduce the loading time of save files, including machines and environmental objects.
[*] Optimizations for specific machines such as conveyors to reduce the overall amount of CPU usage.
[*] We’ve made some pretty big improvements to the way we handle research cores for core composers, making them much more performant.
[*] Terrain mesh generation has been rewritten to be much more performant, this impacts both loading times and runtime modification of voxels such as when using the M.O.L.E
[/list]
These optimization efforts have enhanced Techtonica’s performance and stability, by leveraging Data Oriented Design, the Burst compiler, and the Job System, we’ve managed to reduce memory usage, improve CPU and GPU efficiency, and minimize loading times. As we continue to refine and optimize, we look forward to delivering an even smoother and more immersive experience in the upcoming 1.0 release. Thank you for your support!