A B C D E F G H I J K L M N O P Q R S T U V W X Y Z #

Stormworks: Build and Rescue - Vehicle Optimization

Written by Dmitriy Borisov   /   Updated: Jan 22, 2021    


A short guide that will help you to optimize your vehicles and increase game simulation speed. Please, read if you want your creations be the best (even if they are already).

Basics



Before we start let’s get familiar with how the game works. It will help you to understand the basics of the physics simulation and game rendering.

Stormworks runs in multiple threads. If you press F1 key in the game it will open a profiler that showing a very detailed information about each thread in real time (main rendering, logic, physics, ocean and network). But for now we are interested in only two of them: physics and rendering.



Physics/logic represents the basic simulation of the game that runs at 60 ticks per second (hereinafter TPS). When simulation is stable at 60 TPS the game runs fine but when the scene is getting more complex (spawned additional vehicles, created collisions, explosions, etc) then we are getting a slowmo effect.



Rendering is independent here, not tied to physics and logic which allows players to have good framerate (hereinafter FPS) even if simulation is going slower. If you have a good GPU then more likely you will never experience any issues with most of the creations. Otherwise, especially for the integrated graphics I would recommend you to turn off all shadows and light volumes effects in the game settings.

Now by knowing this you can always hit F1 and see what kind of lag you are experiencing and based on that you can follow next vehicle optimization steps. Actually, I would recommend following them even when you don’t have any issues with your creation. Especially if you want to share your vehicle or environment mod on the Workshop. Stormworks players have different systems and one and the same creation can perform absolutely differently on them. More than that there are many players who love to play in multiplayer which usually means having multiple vehicles on scene.

In other words, even if you are making a simple car or a small boat or a tiny helicopter - you should think about optimization too.

Physics



Being a physics sandbox game it becomes pretty obvious that in most cases the bad performance will be caused by very complex physics of one or multiple creations on scene. Stormworks use Bullet physics and depending on your processor it can work very differently. In short, the Stormworks is a CPU expensive game. You are experiensing a slowmo effect when spawn your vehicle? Press F1 and check the TPS - I bet it will be because of the physics. Time to buy a top-notch CPU? No, you better just optimize your creation.

There mainly only three parameters that we should take into account when designing a vehicle or an environment structure: the shape, the size and the number of the bodies. Let’s start with the first one.

Shape



In most of the games the vehicle physics is just a couple of boxes, cylinders and spheres. Such simple physics allow having many vehicles on the scene without any significant impact to performance. More than that it also takes fewer data be synced in the multiplayer game.



But Stormworks is a vehicle construction game that allows players to build their creations in a way they want using many different blocks. There are many components in the inventory and most of them usually have a very simple physics shape - a cube. The component may look complex but physically it will be very simple. Here, for example, a small engine that made of 27 cubes (3x3x3 voxels):



Each voxel of your vehicle is usually just a cube unless it’s a wedge or a pyramid. But when we create our vehicles we use very many of these simple cubes and eventually can end up with a very complex shape of the vehicle. A good thing here is that when a vehicle is getting spawned the game is trying to optimize the physics shape. You can see it by enabling Physics Debug by F2 hotkey.

For example, if you will make a simple 5x5 plate using regular blocks it will be just one big plate shape ( not 25 small cubes). If you will make a hollow cube using these plates it will be just six plates. And finally, if you will make that cube solid (fill with blocks then) it will be just a cube again.



In other words, a hollow cube is more complex for physics than a solid one. The same way it works with the wedges and pyramids but just more complicated.

Unfortunately even with that automatic physics optimization it often may not be enough. Especially if we talk about medium and large vehicles that can be entered by players. Vehicles with interiors, rooms, trunks, service shafts and many other areas. This will drastically fragment the physics shape which will cost performance.



The solution here is to decrease the number of gaps and hollow places in your creation. Always try to make the shape be more solid and smooth in any part of your vehicle wherever it’s possible. When it comes to hollow areas then today it’s a much more simple task with a new component called a Physics Flooder.

In simple terms, it fills the hollow area (must be a fully enclosed compartment) of your vehicle with massless physics which on spawn makes the physics of that vehicle part much more simple. From my tests I would say it usually saves from 10 to 30 TPS depending on the vehicle.

I would say that the most common use case will be the hull of the boats and ships. More commonly the bow and stern parts. Here an example of the bow:




While it looks very smooth from the outside it doesn’t look well from the inside. Smoothing with pyramids and wedges will surely help both the look and the physics here but I would recommend just to use that new Physics Filler block (just place it inside):



As you can see the bow is not that fragmented anymore and it makes physics calculations much more simple and fast.

But with that block there need to take into account a few moments:

  • The areas must be fully enclosed to make physics flooder work with specific part of the vehicle
  • The areas you fill with that physics flooder will not be accessible for players or any other objects. Same goes for the sub-bodies - if you fill a compartment where you have a pivot or any other mutli-body component it will create a constant collision and your vehicle will fly away on spawn
  • The physics flooder can only fill empty voxels which means that it’s always better to leave only cube-shaped components in the area that you are going to fill with the physics (in other words - just delete/replace with cubes all wedges and pyramids that you have inside)

Bodies



The body is a physical part of the vehicle that can be connected to another one through some joint connection (sub-body) or just can be a completely separate part of the vehicle (sub-grid). We can see bodies when entering the Merge mode in the Vehicle Editor. Each vehicle is at least one body. Here is my jeep, for example:



It’s a very simple vehicle with no doors, hood or trunk. A little more complex vehicle will look like that:



The more bodies you have on your creation the more possible collisions between them and other physics objects there needs to be calculated. The solution here is pretty obvious - try not to use many pivots, pistons, linear tracks and other multi-body components unless it’s really unnecessary. Some small vehicles with dozens of bodies can lag your game more than a medium ship.

Size



Third parameter is the size. All pretty clear here too - large creations will have bigger collisions and potentially will have much more fragmented physical bodies or/and their number. There is no universal solution for large vehicles. You are for a 100% should complete the shape optimization first but if it’s not enough then you will need to make compromises - either you are making a very detailed large creation and play in a slowmo or you make it less detailed inside and enjoy playing with a good TPS/FPS.

Lights



Lights and specifically the spotlights are very GPU expensive. Excessive usage of them will lead to low FPS. Means that unlike the physics lag it will not cause any issues with simulation speed but just will affect your framerate. The recommendation is very simple here - use spotlights only when they are really necessary and try to not duplicate them.

Here an example. That rally car that IRL has six auxiliary lamps but for the game you don’t really need that much. Even if you really will drive at night there won't be much difference between having all six enabled or just two.



Simple math - the left car makes my FPS be around 90 while the right one with just two spotlights allows me to play at 140 FPS. Now imagine what will be if you will race in some multiplayer event and other players will have that or similar car with extra headlights too. It will be a slideshow that’s for sure. You can test in on your own by just spawning multiple vehicles and enabling the lights (or just spawn the spotlights only).

I would say that if you really need many spotlights for a better look then you can leave only two of them powered so the rest will be just decorative.

Cameras



One of the best features of Stormworks are cameras and monitors. Picture in Picture is rare in videogames because of one simple reason - it’s a very very GPU expensive feature. Thankfully, unlike the lights we have some kind of fool-protection here - the more PiPs are rendering the lower monitors framerate which saves our FPS and usually keeps it at playable rate.

But even with that I would strongly recommend to not use excessive amount of cameras. Place only ones that are really needed, always make then be off by default and also try to make them switchable. It will allow players with bad GPU enjoy your vehicle by just disabling monitors or cameras.

Effects



And the last but not the least thing that can also affect performance - the particles.

There are many components that generate different particle effects: foam, exhaust, water, fire and so on. The more these components you have, the more particles there will be. There is an optimization too but it’s just a limit of how many effects can be at a time. That may ruin the look of some vehicles so it’s better to design your vehicle wisely.

Try to not place too many fluid ports, jet exhausts or SRB boosters. Instead of multiple small components it’s better to use their bigger versions because they usually provide a better performance. Particularly for the exhausts, for example, you can use a new Catalytic converter that you can find in the experimental branch of the game.

Written by Dmitriy Borisov.