Category: Nebulis Entity

Real-time Shadows

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.

Nebulis Entity

I know I haven’t posted recently, but progress has not stopped. Well, kind of. The RPG game that I’ve posted about in the past has been put on hold, and I switched gears over these last 3 months to a game with a simpler idea.

I felt that my previous game idea just kept unwinding into a bigger project every day I kept working on it. A lot of progress has been made on it since I last posted, but I thought it’d be good to do something way smaller in scope and then go back to it later.

My new and current project is a 3D game where you and optionally some friends perform research on entities on a space station above a recently discovered planet. I’m nearing a demo-able state of the game and promise to put more information soon. To give you an idea of the aesthetics, here is a photo of a vending machine that you can use to obtain a snack to fuel you during your hard work aboard the space station.

The status screen portion of that vending machine is replaced by a UI when you’re in game.

This game idea may sound complex too but I feel I’ve already gotten more content in this game in 3 months than my previous game, I feel like I’ve defined this game a lot more before starting any development which has helped. Also, there’s not much in terms of combat which I struggled to get feeling right in my RPG game. Anyway, I’ll definitely be putting more posts here soon.

More to follow,

Fouf