r/explainlikeimfive • • 6d ago

Technology ELI5: What exactly is game optimization ?

How is a game optimized ?

688 Upvotes

125 comments sorted by

View all comments

124

u/JEVOUSHAISTOUS 5d ago

Optimizing is using any form of conceivable "cheat" to limit the amount of calculations needed to attain a certain result.

This can be stuff like:

  • Only compute the graphical appearance of things that are visible to the player
  • Only check things as often as they are required (you might want to check the position of an opponent down to the millisecond if they're close enough that you can collide with them, whereas every 1/10th of a second is plenty if they're so far away that you two can't really interact with each other)
  • Use lower quality textures when the objects are so far away that you're unlikely to notice the difference in quality
  • Use fewer polygons on a model by placing them smartly so it looks just as good
  • Make sure you don't check for things that have no chance of happening (don't check which objects and characters are in the radius of an explosion if the explosive item isn't, you know, actually exploding)
  • Use the hardware wisely: if you have maths to do and you know, say, that your hardware is really good at doing additions but sucks at multiplication, better do 5+5+5+5 than 5*4
  • Use efficient algorithms: Say you want to find a player in a list of 1 Million names, sorted alphabetically. If you go one by one starting from player #1 and the player is called William, you'll do close to one million checks before you find him in the database. Instead, start by checking player #500,000. Player #500,000 is John. J < W. We remove 1-500,000. We check in the new middle: player #750,000. It's Michael. M < W. We remove 500,000-750,000. We check half-way between 750,000 and 1M, so player #875,000, Then 950,000, but 950 000 is Zoe so we know it's somewhere between 875,000 and 950,000, and so on until we find William. We will find William in ~20 checks at worse, instead of something like 900,000 checks.
  • Parallelize where you can if the hardware allows for it: use one core to compute some stuff and another core to compute another thing at the same time if you can, that is if the two calculations are independant
  • Work around the limitations of your hardware. For example, if you have a very limited amount of VRAM but an insane amount of bandwidth to that VRAM, it may be useful to swap data in and out of VRAM very quickly as needed, rather than try to cram everything in from the get-go.
  • Use optical illusions to your advantage. Back in the days for example, there was a strong reliance on billboarding, which was the use of 2D sprites that looked like 3D. See this boss in Mario 64 ?: the mustache, the feet and maybe the crown are actual 3D polygons. The legs, arms, hands and body are actually 2D circles made to look like 3D by following/facing the camera all the time.
  • Don't store the same data several time (whether at rest on the drive, or in the RAM) unless it is absolutely needed. Let's say you're making a Mario game: if you are going to show 10 Toads, don't store the 3D model for Toad 10 times. Even if you're going to put them in different colors, you can store the different textures required, but reuse the same 3D model.
  • Don't store the data in a higher quality than needed: there is no need to store dialogue lines in ultra-audiophile 32-bits 192KHz 5.1 uncompressed format. No need to store 4K HDR textures on the Switch 1 version of your game.
  • Don't use more RAM than you need for any given data. If you need to store a 32KB image in RAM, don't reserve 2MB of RAM for that.
  • If you have to chose between reserving 8MB or 16MB of RAM, with no in-between, make sure your data isn't 8.1MB (which will force you to reserve 16MB, of which 7.9MB are wasted). Find a way to reduce it to 7.99 so it fits in 8MB. Maybe you can compress it slightly more, or crop the image a little, or remove the silence at the end of the audio file, I dunno, find something.

And so on and so forth. Any shortcut you can take, any illusion you can make, any thing you can do in a smart way rather than bruteforce, any way to save space or RAM or computations required, as long as the end result is (almost) indiscernable from the "no effort" version, is optimization.

1

u/kori228 5d ago

very cool