• Register
Post news RSS DevLog: Don't Break that Window!

In this devlog I tell you a story of stupid mistakes I made to hopefully entertain you and talk about some fun principles and theories.

Posted by on

Hey folks,

many of you might be familiar with impostor syndrome, where people doubt their skills and have the (unjustified) fear of being exposed as a fraud. I don't suffer from it, but I am also not always completely confident that what I do is great.

I have a motion design background and don't consider myself a programmer first. Sometimes I fear that programmers might laugh at my blueprints and look down on me because of my lack of formal education in programming. So today I want to face that fear head on. I will tell you something that makes me feel stupid, but hopefully it will be entertaining and maybe even encouraging and educational.

Perhaps you have heard this quote from Michael A. Jackson before:

The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only): Don't do it yet - that is, not until you have a perfectly clear and unoptimized solution.

I always followed this principle quite closely ;) But I recently decided that in one specific part of BattleJuice Alchemist, I had to do some optimization. Let me give you a very brief introduction to those of you who are not familiar with optimization at all. So we have a game that we want to run at 60 fps in the end. This means we want a frame time of 16.66 ms, which is kind of a budget we can spend on calculations. I have recently spent a bit too much of my budget, so I decided to take a brief look at what I can do to reduce it. I quickly found out that my bottleneck was not the GPU, but the CPU. There is this fancy tool for Unreal Engine called Unreal Insight that allows you to find out where exactly your budget is spent. I took a closer look.

UnrealInsights 3MB


Turns out that the UI is what caused a quite considerable hit on performance of about 3 ms, so this is what I decided to tackle. I guess many of you who ever worked on a game can relate to what I am about to tell you. You are at the early stages of a prototype and all you want to have is e.g. this icon that shows that the player is low on health. Unreal has this nice drop-down menu that allows you to tie the visibility of your icon to a function that decides whether the player is low on health or not and then spits out "visible" or "invisible".

BindingVisibility 3MB


Unfortunately, this causes the icon's visibility to be set visible or invisible every single frame. No big deal, your prototype still runs perfectly. But fast forward 4 years of development and things start to add up when there are a bazillion UI elements and many are unnecessarily manipulated every frame. I was aware that I was doing something bad all the time, so why did I continue? It all comes down to this first icon...

Have you ever heard of the Broken Windows Theory? Let me quote Wikipedia:

In criminology, the broken windows theory states that visible signs of crime, anti-social behavior and civil disorder create an urban environment that encourages further crime and disorder, including serious crimes. The theory suggests that policing methods that target minor crimes such as vandalism, loitering, public drinking, jaywalking, and fare evasion help to create an atmosphere of order and lawfulness.

BrokenWindows 3MB


So when I used Unreal's option to quickly bind the visibility of my icon, I broke the first window, which I should not have done. Or at least, when I implemented the second icon, I should have fixed the first and done it right for every following icon.

Jackson's Rules of Program Optimization are great and you should not optimize prematurely. But this does not mean you should spend your frame time budget on unnecessary things because of your laziness like I did. And especially you should not knowingly do something stupid, decide everything is fine, repeat it a hundred times and still expect everything to be fine ;)

I hope you liked reading this unusually text-heavy devlog as much as I did writing it. If you want to chat about gamedev or stay up to speed with BattleJuice Alchemist, you can join our Discord.

Thanks for reading and have great weekend!

Alain

Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.