This week’s dev update will be centered around more of an in-the-background element of what’s coming in v0.1.2. It’s an important one that will help with performance, so we thought we’d get a little closer to it for a look at exactly what we’re providing and improving. Richard, our Game Director, helped me (hi, it’s Joey!) draft this post.
Before we get there, just a reminder: Techtonica v0.1.2 is still slated for a late-October or early-November release. We’re closing in on that date with each passing weekly update, so stick with us as we slowly pull back the curtain on what’s included. Last week, we detailed some of the video and gameplay settings inbound with the update.
Today? Today we’re talking Machine Streaming.
“What’s Machine Streaming?” Great question! Let’s dig in.
“Really, stop dodging the question; what’s Machine Streaming?”
Hang on, okay. Let’s start with problem #1…
In the river biome alone, there are about 180 million voxels of space. That’s space players could fill with 180 million stack inserters if they wanted (please don’t do this). It’s cheap to render and animate inserters; but, do anything 180 million times, and things might get out of hand.
Let’s continue this thought experiment of placing 180 million stack inserters. Now you, a player standing near PT VICTOR, will see only about 800k inserters in front of you. That’s only 0.5% of the total.
So, why bother animating or rendering the rest?
The factory simulation runs independently of the visuals, and we, therefore, only load in and process the visuals for the inserters that are actually on the screen. We refer to this trick as Machine Streaming, and it has been mostly in the game since v0.1.
But there’s more!
Okay, but how does Machine Streaming improve in v0.1.2?
To understand how we’ve improved things, we need to talk about problem #2…
Unity (boo, hiss!) is designed to tether just about everything you see in the game to a piece of data called a game object. Game objects come with a lot of stuff that can be useful in various scenarios, but when you don’t need all that information or extra processing, there isn’t a way to get rid of it. This isn’t usually an issue for many games, since we’re talking about very small amounts of overhead, but even with machine streaming, we’ve still got 800k inserters on screen, and each inserter comes with 14 game objects, so we’re talking 11 million game objects!
Multiply all that tiny Unity overhead times 11 million and now we’re looking at a very large amount of wasted RAM and CPU time.
But fear not, we don’t need 11 million game objects; we actually only need 14 of them.
The new and improved Machine Streaming in v0.1.2 skips past the Unity overhead and only uses the original inserter objects as a template. Everything else we need to render and animate 800k inserters goes into a giant list of precisely engineered data to only use up the RAM and CPU necessary to render and animate each Inserter. We don’t need to store the data for where to render the inserter map markers, how big the collision bounds are, what material the inserter uses, what mesh it uses, the color of its lights, and much more 11 million times. We only need to store it once. The new and improved Machine Streaming does exactly this.
Now when you make a ginormous factory, we do not have tons of wasted RAM and CPU overhead over managing and spawning these objects!
And it gets better! Every game object in Unity comes with what is called a Transform. Transforms are pieces of data that just store the position, rotation, and size of the objects in the game. Transforms are rather expensive to update in Unity, but the new and improved Machine Streaming in v0.1.2 does not use transforms! Instead, we efficiently store all of this data in a way that is super fast to update and stream in and out. This vastly reduces the amount of hitches you may experience as you wander around your factory.
Previously, Techtonica would be working quite hard to update all the game objects and transforms as we stream in the visuals for the machines that you can see, but now we’ve cut all of that overhead out!
Additional wins include being able to do things like separate collision detection from the machine animations. Now, instead of there being a collider for the floor 100m away that you cannot interact with at all, we only load in the collision data for the machines within range of player interaction!
How many FPS will players gain with Machine Streaming in v0.1.2?
That’s an incredibly nuanced question with many answers. The new and improved Machine Streaming is primarily targeted at two things: reducing the hitches players experience while walking and the RAM consumption of large factories. It is not simple to measure how much Unity overhead we have cut out when we don’t have access to their API, but players should experience higher frame rates in large factories. Reduced RAM usage should also reduce the likelihood of crashes on Xbox platforms.
I want to reiterate: this is not an optimization to improve performance on smaller factories. These Machine Streaming updates are an investment we have made in our systems before we start giving players tools to build really massive factories and give them new places to build those factories. Yes, it comes with some performance improvements in large factories, but most importantly, this optimization lays the groundwork for many future performance improvements we’re planning to make that were impossible without this new Game Object-less Machine Streaming system.
So, what’s next for simulation system improvements?
Now that we have Game Object-less Machine Streaming, we can start talking parallelization!
The factory simulation must be done (mostly) sequentially, but the same is not true for updating the visuals to match the simulation. It doesn’t matter whether we animate a Smelter or an Assembler first, so why not let them happen at the same time with multi-threading? Previously, using Game Objects and Transforms would have made this task quite challenging, but our new Machine Streaming system is set up such that parallelization is a possible upgrade we can make in the future!
And this is just the tip of the iceberg. As we continue to add more content to the game, we are constantly working to push more and more of these optimizations so that players can build bigger and bigger.
We’ve been really inspired by all of the factories we have seen so far, and we are very motivated to keep improving the game to see what you all can do!
By the way, we’ll be at Tokyo Games Show!
Yes! Techtonica was selected to participate in the TGS 2023 Indie Select 80. If you’re reading this and you plan to attend the show, stop by our small spot and say hello. I (Joey) will be there!
That’s it for this week’s update. We’ll be back next week with more detail on Techtonica v0.1.2.
As always, you can join our Discord to hang out with our community and chat with our team. Find us at https://discord.gg/techtonica.