Devlog #2 - Optimizations


As I was travelling earlier this month, I gave a shot at using my Steam Deck as my primary development machine for a couple of weeks.

At the time, I had already introduced gamepad support into Tunnet and somehow assumed that it was sufficient to make it playable on this platform. But as I started using it more recently, I quickly noticed that the framerate wasn't as stable as I initially thought.

Some of the complex areas made the framerate drop to 40-50 fps for no obvious reason: so I decided to spend some time investigating.

After a few hours profiling the code (using tracing spans already built into Bevy), I quickly realized that there wasn't any obvious/single bottleneck but rather an accumulation of small inefficiencies which somehow were noticeable only in the most complex scenes of the game.

Here are a few issues I identified:

  • The character portrait displayed during the dialogues was rendered even when it wasn't shown. Of course, the performance issue still remained when the dialogues were running, but disabling it significantly increased the framerate, which led me to investigate more in that direction.
  • When I first introduced a second camera for the character portrait, I started to observe some weird behaviors in the frustum culling, so I disabled the entire visibility testing function since I didn't know how to fix it at the time. The performance impact wasn't that noticeable on the simple scene I was using at the time. Time passed and I kind of forgot that I had the frustum culling and render layers completely disabled the whole time: the portrait camera was trying to re-render the entire scene instead of the single character model.
  • Shadow maps are somewhat expensive. But many scenes looked "cheap" when disabling the shadows, so I simply used less of them. I modified the scenes so that none of them use more than a couple of light sources with shadows enabled. I also reduced the resolution of the shadow map quite a lot which still matches with the low-poly/pixel art style of the game.
  • I reduced the samples used by each pixel in my custom Screen-Space Ambient Occlusion (SSAO) implementation. This was hurting the performance a bit and dividing the amount of samples by two helped a lot but made the output slightly more noisy (especially on bright textures). After tweaking a few parameters, the new ambient occlusion makes the game look slightly more cartoony than before but it is now a bit faster to render.
  • While most of the optimizations happened in the rendering side, I also noticed that the physics engine started to slow down on complex scenes with many rigid bodies. Reducing the number of the physics steps per second seems to help in some cases without impacting the gameplay experience too much.

After making all these changes, the game now seems to render at a stable 60fps on my Steam Deck in all the scenes I tested. Woohoo!

While working on these optimizations, I also found the time to make some smaller changes:

  • Some of the textures have been revamped and are now slightly more detailed:
  • A couple of new animations have been added to the dialogue portraits:

  • It is now possible to sprint by holding the Left Shift key:

  • The fullscreen mode has been added and the mouse movements can now be inverted in the settings menu:



  • As several players reported that the demo crashed on their system, I also added a basic crash reporter. It automatically generates a minimalist crash  report and opens a small dialog box that allows the players to view, edit and  send the report if they wish to.

I just uploaded a new version of the demo which incorporates all these changes. 

Have fun!

-- 

Puzzled Squid

Files

tunnet-windows-demo.zip 37 MB
Version 7 Aug 26, 2023
tunnet-linux-demo.zip 34 MB
Version 7 Aug 26, 2023

Get Tunnet

Buy Now$5.99 USD or more

Leave a comment

Log in with itch.io to leave a comment.