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

2.16K 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

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.

You are viewing 1 out of 105 answers, click here to view all answers.