Edit: Really enjoy threads like this, because you learn and see so many Pov.
My favourite answer (not in this thread unfortunately) was:
*”If you write a story, the number of words you use can affect the reader’s experience.*
*Use too many words, and the reader takes a long time to get through the book, has difficulty remembering everything, and can’t separate what’s important and what’s not.*
*But use too few words and the reader will get an incomplete picture, make mistakes in understanding the story, and eventually become disinvested in the book.*
*A poorly optimized game is like one of these examples. Either too much goes in, making it difficult for the hardware to cope, or not enough goes in, making the game buggy and broken. (Sometimes both, but that’s beyond ELI5).*
*When it comes to optimising a reader’s experience, it is not about putting more or less words in but choosing the right combination of the right words at the correct time in the plot. Optimising a game is similar concept.*
*Most importantly, no matter how well you write a book, there are always people who will think it could’ve been written better, especially by them. “*
In: 404
A lot of examples are already given, but lets keep it simple with an example that a 5 year old can follow.
Games use a lot of math in the background, so lets say you have a number, and you need to increase it by 5. An non optimized game would take the number, add 1, take the result, add 1.. etc until it has done this 5 times. That’s 5 calculations. A bit like how you would count on your fingers, one at a time.
An optimization you could do is just take the number, and add 5, that is only one calculation for a computer.
This is oversimplified, but a lot of games do unnecessary loops like this as it is often simpler, and it might work fine in the beginning, but when you add more content to the game it might not work so well anymore. Another example that i’ve seen in real programs is when you have a database, for example all items in the game. To get one item, they request all items from the database and in the code they use only the one they want. This works reasonably fast when you have 10 items in the database, but is very slow if you have 10 million items. An optimization would be to request only that specific item from the database.
So there’s a lot of elements in a game – models, textures, sounds, lighting, particle effects, to list just a few. A lot of this is down to a mix of balancing visual fidelity with how smoothly the game runs.
Models (as in the physical forms that players, enemies, the world takes) are made up of polygons, lots of little squares. The more polygons that are used to make a model, the higher amount of detail a model has the capability of having, however, more polys = more things for the hardware to calculate. A skilled artist here will look to optimize models by removing unnecessary polygons, i.e polygons that will never face the player like the backs of buildings on a street.
Textures are simply images, so think JPGs, PNGs, TGRs, etc. A single model may used a lot of different textures compiled together into a Material. But like with Polys on a Model, a higher resolution Texture while offering the capability of more detail, also increases the file size and the strain on the hardware.
Sounds are much the same, bit instead with Bitrate. Higher Bitrate = increased capacity for higher quality sound, but also is more strenuous on the hardware.
This same logic applies to all elements within a game, but also to things like whether or not LODs are being used properly (which loads a lower-poly and lower-material-resolution model when far away from something instead of the high-poly high-resolution one), or if render culling (which only shows elements of the world when the player is in certain areas and keeps them hidden otherwise), or many other things.
I can give you a real world example of poor optimisation I encountered on my first games job almost twenty years ago.
We were making a 3D strategy/rpg hybrid and one day QA noticed that our performance had gotten worse and especially in one level, where the game became a slideshow.
It turned out that a junior artist had created a pumpkin model in excruciating detail, modelling every single leaf and bump in it. As you might know 3d models are made out of triangles stitched together. Each on of these triangles needs to be „drawn“ by the graphics card, so especially in the old days, when computers were way less powerful than now, you were always aiming to create objects with as few of those triangles as possible, while still retaining details.
A pumpkin in a strategy game which you usually watch from above can easily be made with a few dozen triangles and still look good.
That particular pumpkin model had over twelve thousand triangles and was placed hundreds of times on the level that had the bad performance, since it featured pumpkin fields and pumpkin merchants…
It was a very easy fix which immediately improved performance. And since this happened during development, no customer ever encountered the pumpkin of doom in the game.
People say a game is poorly optimized when they have top-of-the-line GPU and it still runs poorly. What it does mean in reality– it can be 2 ways:
1) The most common: Game is literally done (or ported to other platform) poorly, even stuttering with newest hardware; in this category falls some anti-cheat, which required to be run along the game, eating computation power by itself.
2) Complaining person doesn’t understand that game itself isn’t only picture, but inner game mechanics and calculations, and they bought top GPU and sub-par CPU. Complaining person can’t comprehend that despite some two games might look the same, one of them have simple gameplay, like “beating enemies with such damage, they have such hitpoints” and that’s all, and other game is calculating every enemy’s gear, skills, effects, sight and hearing, and simulating living NPC gathering resources on the map out of the player’s view. The first one is called by that person “optimized”, and the second “unoptimized”.
Therefore, in point 1 optimization means “rewrite code to make it simpler and more effective”, and in point 2 “get rid of complex mechanics”.
Another example.
Minecraft looks at the terrain and for visual purposes tries to never look up things behind other things. Steve? can’t see through walls, the graphics engen doesn’t need it’s time wasted knowing things are there.
Minecraft items, if you drop a million torches in one spot they become one item and the game engine doesn’t have to keep track of every one.
(I don’t know that it’s currently done this way just that it was)
Counterexample, multiplayer doom, when it first came out each bullet was a network packet. So you and your 6 friends with miniguns kick down the door and find 2-3 spider things with two miniguns each. I don’t remember the exact math but it’s lots of packets, your network has been pounded to a crawl and if it belongs to someone else they are looking for you.
Games Developer and Software Engineer here:
Basically there are loads of ways to do things, and often the quickest way isn’t the most efficient.
For an example, imagine I have a thousand icons on my screen.
A thousand different pictures of different things, and I need them all to appear seamlessly at the same time.
Seems like a no-brainer, I’m going to have to tell the computer to fetch all 1000 separate images from a folder and display them, which is going to take a moment.
Except.. that’s not the only option. We can do something called a Sprite-Sheet.
Basically we just put all 1000 icons on one big image, and fetch that one image. Which is much much faster than a thousand separate requests.
Then we can simply display the parts of that image that we want, because we can easily store the position and size of the part of the big image that corresponds to each smaller icon.
This is far far more efficient than doing it on an individual basis, but obviously is a bit more complex to set up, so it might well be set aside by a lazy developer.
A simple explanation is that code can be written fast and run slow, or written slow and run fast. You spend initial time writing code that is easy+fast to write (but slow) and then if it becomes a problem you can more time later to rewrite it so it runs fast.
One of the examples, assuming we’re going from zero knowledge is sorting numbers. If you have the numbers 1 to 1000 all randomly arranged, what is the fastest way to sort? The first naive approach would be to go through each and check to see if the one you currently have is the lowest. So if you picked 500, you would go until you have 499 or lower. Once you do, you start over again. Keep going for 1000 numbers. It would take many thousands of iterations to do this, take up tons of CPU and just be a terrible choice.
Now you enter the realm of optimizations and you have to choose what to optimize for. In the sorting example there’s about 100 different options. Some are optimized for low numbers of things to sort, millions of things to sort, CPU optimization, memory optimization, speed etc. One thing to sort may not be like another so you could be using many different sorts.
You can see this visually here: [https://www.youtube.com/watch?v=FNAUuYmkMPE](https://www.youtube.com/watch?v=FNAUuYmkMPE)
[https://www.youtube.com/watch?v=kPRA0W1kECg](https://www.youtube.com/watch?v=kPRA0W1kECg)
Another version of optimization you can easily see is pathfinding. How to get from A to B: https://www.youtube.com/watch?v=g024lzsknDo
I had a trial at a game company in Germany with zero in the name who were working on a game based on a certain top model TV show. They asked me to work on some code written by the lead dev. This was PS2 code and my job was to make.it more memory efficient.
The code is in question was putting clothes on the models. I looked at the code and took out the bit that did the work and saw that it only used 1kb. I was fresh out of uni and had absolutely no idea how to reduce that memory usage further. I realised then that console development was not for me. The optimisation required for a console with limited memory is crazy compared to pc games. Needless to say my trial was cut short.
Latest Answers