The Art of Game Optimization

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
video games have come a long way since the early days most people would probably attribute this to the evolution of Hardware but there is so much more to it than just that the way we make video games have completely changed as well like for example lately we see that games are being released in an unfinished State and are really badly optimized uh when I meant games changed a lot I did not necessarily mean in a good way you see we earn forever improving graphics and while Hardware doesn't need progress like more predicted which seems to be holding up to even This Day graphics will get better but do we not care about users with lower end computers also morla won't hold through forever which he stated himself as we are reaching physical limits the progress of Hardware will begin falling off so we need to optimize but how I am sure that even if you are not familiar with game development you are aware of some of the ways performance is squeezed out of games let me first show you what not to do be me a curious 14-year-old who wants to make a first-person shoot it's the early 2010s okay it's like what are you even doing if you haven't tried making an FPS game around then so you open unity and throw something together where you somehow manage to break the laws of physics in base you've never imagined then you are like H let's BR the quintessential element of any FPS game a door so you open some 3D software and make a door a transform Cube will pretty much do as for the handle H let's extrude a cut in another Cube and slam a subdivision surface on it nice couldn't be simpler let's quickly import it to Unity I'll just make a few copies of it and let's try out the game and I have 20 something FPS so I guess it's quis time what did I do wrong well it's kind of a trick question because it's actually none of those if we go back to Cinema 4D and take a look at the number of polygons on the handle we see that it has over 3 mli million of them that is ridiculously high we need to keep this number in check why well to understand first you need to know how the average render engine works let me present to you the render engine in 1 minute let's go first we need an API to communicate between the CPU and GPU like openg the CPU sends the following three data attributes uniforms and textures the attributes contain information about how the mesh should be rendered using vertices normal and UVS uniforms DET take the world local and Camera space of the mesh the texture is obviously used to color the object all of this data is then fed into a Shader inside the GPU this Shader is comprised of the following parts vertex fragment desolation and geometry first the per vertex operations are performed which alter the shape of the object because it's from the vertices that The Primitives AK the triangles are formed any of which happen to follow the screen are discarded the ones that remain go through desolation for continuity across the surface and are also rized and colored in the fragment Shader with the appropriate texture based on the UI maps for the mesh additionally the geometry Shader can add more vertices based on our needs the mches now most commonly leit with diffus lighting based on the light Direction material colors and normal vectors but on top of this we have speckler emissive and ambient lighting too o did you get all that good me neither but it's fine all you have to understand is that the number of triangles have to be kept at a minimum this is what gives older games the characteristic look with all the edges next let's talk about materials materal actually make up a good portion of the size of modern games they are also responsible for most of the memory usage the obvious way to improve performance here is to make them smaller and compress them Reserve large scale textures only for objects that are important and are in the focus of the game since objects generally require multiple textures to look good Channel packing is a neat trick used in most engines to save on RAM and sampling operations basically instead of having the textur separate They are packed into the different channels of one file so this is cool and all but we have barely scratched the surface so far these were just the basics the tip of the iceberg we shall now dive under to explore the advanced stuff starting with LD or level of detail this is an old technique where one object will receive one or multiple reduced polyon version of itself that we progressively iterate through the further the object is from the camera as it's not like we could see small details on distant objects the problem with this method is the work you have to put in to create all the models for some time now people have tried to make this all automatic and dynamic but it wasn't until onreal Engine 5 that we got a really impressive solution called nanite nanite reduces triangles dynamically allowing close objects to be highly detailed and it gets rid of the nasty line between lods as those are not required anymore everything is lit evenly with the Lumen illumination system talking about lighting the biggest step forward in recent years was R Racing AKA realtime lighting race hav been traced since 3D software has been a thing so basically seems forever the key difference here is this being real time retracing is still difficult to incorporate into a game without having to kill the rest of the settings though so we still have some ways to go there but then there is black magic like dlss AI is showing up everywhere lately and it's being used to upscale images too Ambria is upscaling real time gameplay essentially using Ai and who knows what other ways AI will make its way into games but now we are quite deep but it's time to go even [Music] deeper code write one on necessary if statement and you can throw all your optimizations out the window but how do we tell if a piece of code is slow once again it's a game of numbers let me present to you the Big O notation this tells you how complex and algorith is by showing how the number of operations grow as the size of the input data grows uh let me tell you a story there is this game I used to play that isn't dying or anything or at least that's what the devs like to think anyway it had a cool little Easter egg with a blinking light it looked like Mor code so I tried translating it only to realize that there were no pauses which is kind of needy to tell where letters end and begin sounded like a fun puzzle though so I tried writing a program for it don't worry this lead us back to the bigo and code optimization in due time so my idea was to make every possible combination of spaces and translate all of them how do you do that though one day in a boring class I had an idea use binary numbers let's make a binary number as long as many spaces there could be in the word and say that every one is a space and every zero is not a space then just count up and you will get every combination I pitched the idea to my friend who made quick work of the this the code may not be the nicest thing you've ever seen but we made it in our first year of learning code so I think it's all right from here it was as simple as translating each word and checking against all English words I found a txt with 370,000 of them after doing some tests it seemed like it was working so I guess it was time to try it with the real code all right this will take a while because we are checking 262,000 variations against the entire 370,000 word list that's nearly 97 billion checks but hey we got our word dunker the game does have a ship Nam dunker but apparently the messages are related to the current update of the game and the time this code is from has not much to do with dunker so I don't actually really know what the code is supposed to be even online people don't really seem to agree anyway to to get back on point this code has exponential time complexity with a big old notation no better than 2 to the power of n due to the binary getting twice as large with each increase in length increasing the character count by just three already gives us 770 billion checks in another three characters and we have Six Trillion combinations which would take years to go through which may remind you of how passwords become near impossible to Brute Force if they are long enough now you may be wondering how can we make it faster but one specific thing that could help this code is the fact that modern CPUs have multiple cores we can split simple tasks among the cores to compute them in parallel this becomes most useful in games with a lot of simulation like tycoons and city builders take into account however that you cannot just throw multi- trading at anything for example in my code multi- trading is actually slower sometimes probably due to the overhead that threading comes with as well as the nature of the task among other things also maybe because I suck at coding but for this reason I callab with my friend again who had an idea what if I told you that this problem has a linear solution our approach back done was all wrong let's instead just translate the list of words to spaceless mores and just look up our code this way the worst case scenario is if we have to check all the words in the list but even that only takes a few millisecs even with really long words that's a pretty good optimization I would say now I won't be getting into translating entire sentences because that's really hard actually and my head already hurts so what did we learn with all of this well the game optimization is hard blame Falls not usually on the game artists and programmers but rather management game def H is not something that contractors are familiar with and does the Crunch and tight deadlines forc the deps to cut Corners notice how most games that usually release in an unoptimized state had also been delayed remember that you vote with your wallet so vote for the games that are in the state that you want to see them in
Info
Channel: Worlds In Motion
Views: 257,873
Rating: undefined out of 5
Keywords: game, optimization, 3d, visual, comparison, progress
Id: l_JAk9xGMvk
Channel Id: undefined
Length: 10min 18sec (618 seconds)
Published: Sat Oct 21 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.