How does game “optimization” work? Are people sitting there changing lines of code to more “optimal” ones? What is “optimized”?

2.06K views

The recent The Last of Us for PC made me realize I had no idea what’s meant by “optimizing” a game.

Same with optifine in Minecraft improving performance. How do these things work to just make games use fewer resources?

In: 158

105 Answers

1 2 4 5 6 7 8 10 11
Anonymous 0 Comments

It’s hard to be specific because optimization revolves around knowing how your game specifically works, and then seeing where you can get rid of unnecessary work.

On the code side, it’s often a choice between speed and memory, so it only makes sense to make these changes once you know which ones you have excess of in certain areas of the game, and which one your running out of. You’ll also have a better idea of when you can “cache” data, i.e. process something once and reuse it later. The opposite is also true, if you’re running out of memory you might choose to stop caching data and just take a small performance hit in reprocessing the data, but try to time it for a point in the game where you can sacrifice a few FPS.

On the art side, once you know the models are locked in and aren’t going to be changing you can start merging them together (less individual models means they render faster) and other things that might screw up the workflow if you ever wanted to change them, but allows the computer to work with them better.

Anonymous 0 Comments

In general optimizing something just means “making it better” or closer to the optimal, i.e. best possible performance.

When discussing optimizing code, there are two main focuses; optimizing memory usage and optimizing processing speed. In general you achieve one of these by sacrificing the other.

For example if you are designing a game for an older console system, you’d want to focus heavily on optimizing the usage of the limited, non-upgradable RAM memory. That means getting creative with how you fetch and store data in your code so that your game doesn’t max out the available memory.

If processing speed is the end-goal, then often that means sacrificing some memory optimization and storing more information in RAM and using creative algorithms to process data more efficiently.

To be more precise programmers can evaluate a piece of code and give it a complexity value that essentially tells other programmers how efficient/optimized it is for memory and speed. Check out [Big O notation](https://en.wikipedia.org/wiki/Big_O_notation) and [computational complexity](https://en.wikipedia.org/wiki/Computational_complexity) if you want to learn more about that.

Anonymous 0 Comments

It’s hard to be specific because optimization revolves around knowing how your game specifically works, and then seeing where you can get rid of unnecessary work.

On the code side, it’s often a choice between speed and memory, so it only makes sense to make these changes once you know which ones you have excess of in certain areas of the game, and which one your running out of. You’ll also have a better idea of when you can “cache” data, i.e. process something once and reuse it later. The opposite is also true, if you’re running out of memory you might choose to stop caching data and just take a small performance hit in reprocessing the data, but try to time it for a point in the game where you can sacrifice a few FPS.

On the art side, once you know the models are locked in and aren’t going to be changing you can start merging them together (less individual models means they render faster) and other things that might screw up the workflow if you ever wanted to change them, but allows the computer to work with them better.

Anonymous 0 Comments

the larger the code for something gets, the potential for unintended interactions increases exponentially. sometimes optimizing means to remove those unintended interactions, but sometimes you find ones that help and you then try to implement (“it’s not a bug, it’s a feature” type of thing). sometimes those unintended things are quirks of the language they are using, or for consoles if there is specific hardware the developers learn how to exploit as they gain experience. an example, in C++ the operation “i++” takes 2 or 3 processor cycles more than “++i”. a small amount to improve, but if you need i to count to a million, that’s 2-3 million processor cycles saved.

Anonymous 0 Comments

In general optimizing something just means “making it better” or closer to the optimal, i.e. best possible performance.

When discussing optimizing code, there are two main focuses; optimizing memory usage and optimizing processing speed. In general you achieve one of these by sacrificing the other.

For example if you are designing a game for an older console system, you’d want to focus heavily on optimizing the usage of the limited, non-upgradable RAM memory. That means getting creative with how you fetch and store data in your code so that your game doesn’t max out the available memory.

If processing speed is the end-goal, then often that means sacrificing some memory optimization and storing more information in RAM and using creative algorithms to process data more efficiently.

To be more precise programmers can evaluate a piece of code and give it a complexity value that essentially tells other programmers how efficient/optimized it is for memory and speed. Check out [Big O notation](https://en.wikipedia.org/wiki/Big_O_notation) and [computational complexity](https://en.wikipedia.org/wiki/Computational_complexity) if you want to learn more about that.

Anonymous 0 Comments

the larger the code for something gets, the potential for unintended interactions increases exponentially. sometimes optimizing means to remove those unintended interactions, but sometimes you find ones that help and you then try to implement (“it’s not a bug, it’s a feature” type of thing). sometimes those unintended things are quirks of the language they are using, or for consoles if there is specific hardware the developers learn how to exploit as they gain experience. an example, in C++ the operation “i++” takes 2 or 3 processor cycles more than “++i”. a small amount to improve, but if you need i to count to a million, that’s 2-3 million processor cycles saved.

Anonymous 0 Comments

Optimisation can mean many things. It is just general term. However lets visualise it like this:

How would you simplify 4×7? Well… I was taught to memorise the tables. That is actually a form of optimisation. There is no point calculating it if you can just have table with already calculated solutions. So you can have a table of 10×10 solutions, and look it up there. However 7+7+7+7 as a cumulative method is an easy way to do it also.

So lets imagine you have items in your game with special multipliers, and then stats with special multipliers. Every time you swing your weapon in the game you can do two things: calculate the result, or look up the result. Depending on situation, either can be more optimal. than the other. If you know that you have a dagger with +1 damage, and enemy with -1 to dagger damage. You don’t need to do the maths in-game to solve this. You can have a table to refrence against, and no need to do pointless “Damage +1 -1” maths. This is how it was done on table top. However if you work with percents, your tables can grow really big an burdensome, so calculating it might more efficient.

For optimisation of the graphics, there is an art to it. Quite literally. To turn high polygon detailed model in to one with few hundred, and then simplifying the textures and using maps to pre-calculate effects, lights, and light. This is done by hand, because it requires actual aesthetic choices. If your game has sharp style and very little rounded surfaces. Well you could sacriface detal of roundness, but not of sharp geometry. **Unless** you want to make something stand out by being clearly more rounded. Same thing happens with compression of textures, if you have very little red… it could be more optimal to just disregard that red. If you want something to be really bright against warm colours… Well… You don’t need to add range of contrast or brightness, add cold colours to make contrast stand out as bright. This way you can clamp the ranges, and get an effect of brightness.

For the gameworlds itself. Lots of optimisation is actually done by precalculating things. Go play Portal 2, and turn on the narration bits. In the intro they explain how they were able to achieve that collapse of the walls and the pod you are in, that would have taken lot of work to calculate real time. Well the joke is that they calculated it all real time. The game doesn’t calculate the physics at all on the props. This would been quite feat to do properly for 2011 hardware, and not have it do the “jiggles” and have parts flying to the moon from collisions.

Same thing with lights, reflections and shadows. If you know that a light will always come from on direction and the scene is static. You don’t need to calculate the shadows, you don’t even need to have that light “for real”. You can just precompute it all, and project the shadows and even lights. Suddenly a act of rendering light and shadows, is just a simple task of projecting shapes. Something that computers and game engines are really good.

Same applies for something that is just 2D. If you need something to just be 2D thing and animate. No need for video files or animation frames. Just make a animated sprite of it. You can actually make a cobblestone street and now need more than 2 polygons and have realistic results. Why? Just precalculate the whole thing and have it as maps and tectures. You have turned massive amount of geometry in a simple picture that tells the computer to show things in special way.

Anonymous 0 Comments

Most of the other explanations go over general software and game optimizations, which are (or should be) already routinely performed by the software developers working on the lower layers of the game engine. Whilst this is related to what you’re trying to get at, it’s only half of the picture.
The other half is the fact that the technology stack down to the hardware which the game was originally intended to run on, and the one it eventually gets ported to, can be considerably different. Add to that the fact that the hardware in the PC is a diverse set of parts rather than just 1 configuration.
This is why games need optimizations for a given platform, by which we mean the accounting of these differences by the game developers such that swapping the platform is, at the very least, unnoticeable, experience-wise. As you can tell from the history of PC ports, it’s a complicated problem to tackle.

Anonymous 0 Comments

In general optimizing something just means “making it better” or closer to the optimal, i.e. best possible performance.

When discussing optimizing code, there are two main focuses; optimizing memory usage and optimizing processing speed. In general you achieve one of these by sacrificing the other.

For example if you are designing a game for an older console system, you’d want to focus heavily on optimizing the usage of the limited, non-upgradable RAM memory. That means getting creative with how you fetch and store data in your code so that your game doesn’t max out the available memory.

If processing speed is the end-goal, then often that means sacrificing some memory optimization and storing more information in RAM and using creative algorithms to process data more efficiently.

To be more precise programmers can evaluate a piece of code and give it a complexity value that essentially tells other programmers how efficient/optimized it is for memory and speed. Check out [Big O notation](https://en.wikipedia.org/wiki/Big_O_notation) and [computational complexity](https://en.wikipedia.org/wiki/Computational_complexity) if you want to learn more about that.

Anonymous 0 Comments

Optimisation can mean many things. It is just general term. However lets visualise it like this:

How would you simplify 4×7? Well… I was taught to memorise the tables. That is actually a form of optimisation. There is no point calculating it if you can just have table with already calculated solutions. So you can have a table of 10×10 solutions, and look it up there. However 7+7+7+7 as a cumulative method is an easy way to do it also.

So lets imagine you have items in your game with special multipliers, and then stats with special multipliers. Every time you swing your weapon in the game you can do two things: calculate the result, or look up the result. Depending on situation, either can be more optimal. than the other. If you know that you have a dagger with +1 damage, and enemy with -1 to dagger damage. You don’t need to do the maths in-game to solve this. You can have a table to refrence against, and no need to do pointless “Damage +1 -1” maths. This is how it was done on table top. However if you work with percents, your tables can grow really big an burdensome, so calculating it might more efficient.

For optimisation of the graphics, there is an art to it. Quite literally. To turn high polygon detailed model in to one with few hundred, and then simplifying the textures and using maps to pre-calculate effects, lights, and light. This is done by hand, because it requires actual aesthetic choices. If your game has sharp style and very little rounded surfaces. Well you could sacriface detal of roundness, but not of sharp geometry. **Unless** you want to make something stand out by being clearly more rounded. Same thing happens with compression of textures, if you have very little red… it could be more optimal to just disregard that red. If you want something to be really bright against warm colours… Well… You don’t need to add range of contrast or brightness, add cold colours to make contrast stand out as bright. This way you can clamp the ranges, and get an effect of brightness.

For the gameworlds itself. Lots of optimisation is actually done by precalculating things. Go play Portal 2, and turn on the narration bits. In the intro they explain how they were able to achieve that collapse of the walls and the pod you are in, that would have taken lot of work to calculate real time. Well the joke is that they calculated it all real time. The game doesn’t calculate the physics at all on the props. This would been quite feat to do properly for 2011 hardware, and not have it do the “jiggles” and have parts flying to the moon from collisions.

Same thing with lights, reflections and shadows. If you know that a light will always come from on direction and the scene is static. You don’t need to calculate the shadows, you don’t even need to have that light “for real”. You can just precompute it all, and project the shadows and even lights. Suddenly a act of rendering light and shadows, is just a simple task of projecting shapes. Something that computers and game engines are really good.

Same applies for something that is just 2D. If you need something to just be 2D thing and animate. No need for video files or animation frames. Just make a animated sprite of it. You can actually make a cobblestone street and now need more than 2 polygons and have realistic results. Why? Just precalculate the whole thing and have it as maps and tectures. You have turned massive amount of geometry in a simple picture that tells the computer to show things in special way.

1 2 4 5 6 7 8 10 11