So I recently was having issues with low frames per second in my game that I’m currently working on (more posts to follow regarding it).

My game is networked and I’ve crafted a framework on top of Godot & SteamNetworkingSockets, and I assumed that this foundation that I laid my game upon was inefficient and spent about 4-5 nights improving it and trying to make it more efficient.

I made two big changes to my system:

  1. I use MessagePack for data serialization for all network communication. I do this on the main game thread, and I figured I could improve performance by moving this to two separate threads: one for serializing and one for deserializing. This did not take too much effort to get working, also a by-product of doing this work was I moved allI serialization code into only one place in my code, it was a little bit of mess before and now it all happens right when we send/receive network messages.
  2. Networked objects can have attributes on properties so that field or property can be synced between clients, kind of like a network variable. The way I was managing this was quite messy and I had been meaning to more deeply integrate it into MessagePack and streamline it for a while. This work took a great chunk of my time but I’m happy with how it turned out. I essentially went from a weird system where I sent and stored serialized byte[] information with type information that were deserialized on demand. Now I have it setup so MessagePack can deserialize all that information when the network state is received and it’s stored properly in an object variable, ready to be used whenever.

In the end the frames didn’t change all too much, I may have gained 5-10 fps — but it did make me feel happier to have completed the work.

As the title of this post may have foreshadowed, I pretty much doubled my FPS by turning off shadows on my lights in my game. My game doesn’t have that many light sources with shadows enabled – it seems they’re just quite expensive and it drastically increased the draw calls Godot was making (from 8k~ to 2k~ in some instances).

I still wanted shadows on my SpotLight3D’s though, so I ended up learning about Distance Fade, which essentially disables the SpotLight3Ds shadows if they’re not near the active camera. I also adjusted the shadow settings in the Project settings and reduced the quality of them – my game is going for a low polygon look and I think it actually adds to the aesthetic to reduce the shadow quality.

Distance fade property screenshot:

Lights and Shadows properties in the Project Settings:

In the end I’m back to a nice practically constant 120fps and I still have my shadows – and a nice little rewrite of some aging code to boot.

Thanks for reading & until next time.