5 tips to optimize your UE5 game!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
all right um today we're going to be covering five different tips and tricks to actually help you improve performance in your video game as you can see here on the screen here are the five tips if you'd like to fast forward to a specific one but in general these tips have helped me in Starlight Brigade gain nearly a 50 increase in performance I went from about 60 to 70 frames per second in gain to almost 120. now it does kind of cap at 120 so it could even be higher in certain situations but it kind of bobbles between 110 and 120 so just to be more honest with you it's about a 50 increase so let's go ahead and Jump Right In with tip number one which is actually going to be using our stat unit graph to actually see where our bottlenecks are now this sounds kind of like a the but for a lot of new beginners they don't know about these command lines so we're going to kind of talk about those here so if you hit your tilde key that's the key to the left of your one button and above the tab button it looks like a little squiggly line if you go ahead and hit that you're going to open up a command line down the bottom and you type in stats Space Unit graph so you've got you've got unit graph and then here you can actually type in stat space FPS and these will provide you a couple of different tips and tricks different tools I mean um to actually figure out what's going on I prefer the unit graph because what this does is it provides you your unit graph in the bottom left for a very easy visual way to see over time what's happening so if there's a sudden Spike even if you don't notice it in all those numbers going on on the right hand side on the left you'll see that Spike visually and so with that as you can see here my game currently is running at 8.3 milliseconds and I believe the big thing is is sort of a mixture of your gaming your GPU so your gaming GPU time or Draw time as well draw time is is probably what people pictures your GPU usage so draw time is your actual what polygons you're rendering on screen so if you've got a lot of meshes or a lot of really complex messes you're going to see that draw time go up um your GP to you time is the complexity of like your shaders and everything just sort of how detailed your your materials are very complex materials you're going to see a really high step up in that and then as well you have your frame time which is a combination of your game time which is sort of your blueprint um you know how complex your blueprints are with those other factors sort of combined together because your frame time is your actual time between frames so let's go ahead and also I'm gonna just for to show it off I'm gonna hit stat FPS here and so now you can see that uh we're basically almost locked at 120 FPS right here and that's with four AI enemies who are tracking in on me and everything kind of going on background the only thing I'm not doing yet is I'm firing my engines which does eat a little bit into that but still we're basically locked at 120. that's what I meant earlier about the whole like it could be even higher um so let's go ahead and so now we kind of covered this let's cover some of the different view modes while you're using stat unigraph some handy view modes is if you notice that your draw times really high or maybe your GPU times really high you can hit some of these function keys here at the top and those will give you some different views you can use so F1 this gives you your sort of wireframe view this is a really handy way to quickly glance at anything and notice if any of your messages are a little bit too high poly or or look unusually high poly for some reason you can go ahead and do that F2 is basically your base colors so your diffuses but without any lighting or I think it's technically like it's like a flat lighting um that way there's no like kind of Reflections none of that it's just sort of like what you see at the most simple level you got F3 this is your default view so it's just a regular overview um uh oh is yes and then F4 is without Reflections I believe um I'm not actually sure entirely on that F5 is actually your Shader complexity this is how complex your actual shaders are so you can see for here everything's green and then you have um I believe that is most of them you can hit F10 to save screenshots f11 of course to full screen or not full screen um but yeah so that is pretty much everything when it comes to this first tip so that's a really great way to kind of see you know where you're having the biggest problems what sort of you know your bottleneck for your game and once you find your bottleneck you can move on to your next tip here which is going to be using insights let me actually open up this I like the dock this in the layout for some reason these aren't talking oh I better hit okay yeah there's a key up here uh one of these key Bindings that actually kind of throws everything for a loop it's what I like to do is just go back to Windmill and then load default editor Loadout and then yeah there we go and layout I mean not load up and then just Red Dot this all right so now we're going to do something called insights insights is really really helpful for sort of getting a fine-tuned look at what's causing your performance issues um now with that there's a lot that goes into it and it's still a developing tool but they are replacing front end session with this so this is going to be your catch-all for performance um catching inside of Unreal Engine so what you have down here in 5.2.1 and newer is sort of your buttons here actually it might be in 5.2 or newer I don't remember exactly if they added in 5.2 I just upgraded straight to 5.2.1 um but you've got your Trace button here that gives you a lot of different options but the biggest ones you want to focus on is statinate events which you do have to turn on currently every time you load the engine in the future they'll probably just have that turned on by default if you check mark it or like saved it somewhere um but that is one of your most important ones and then you have a couple options here so there's live session on Trace start you can show and explore after Trace if you want to actually see the trace file itself or you know copy paste it somewhere send it to somebody then you have open Trace insights after Trace so this actually open up the insights program once your Trace is complete which is pretty important if you want to do some profiling um now you have you can trace a bookmark if you have a specific bookmark you want to do um or trace a screenshot but usually what I find is the most helpful is going to be these channels so there's a lot of channels here you don't have to have everything which you want to kind of focus on are the things that are going to be kind of the the most important part of your actual performance profiling so usually I'll uncheck anything that I don't think is very important and then go back in and add additional things so as an example most of the defaults are pretty okay I just usually uncheck screenshots I'm not going to take any screenshots and then I'll check mark physics Niagara object if I was doing any online profiling you may could hit net um and maybe loading time could be handy because you know if you're loading a lot of assets that's that's that's pretty important to know um these are the Koreans um I haven't gotten enough into profiling to know exactly what to look for with these but if you know more a bit more about profiling rhi commands or RDG or even just render commands um definitely you can check mark these as well so let's just say these are the channels we want what you want to do is you want to go ahead and you can either hit start tracing here or you can actually just hit the button down here as well and what they'll do is they'll start tracing and then you can just go ahead and jump into game and you want to play for at least a little bit to get a good you know kind of idea if there's something specific you're wanting your profile so a specific event in game you can go ahead and actually do that um and sort of zoom in on that specific event that you want to to look at or level you want to load but for this since my game's all in one single level I'll just go ahead and hit the gas and uh run some particles there in fact we'll crank up a particle spawn rate like that because it also increases our speed so we can have a little more fun with it all right what kind of do some stuff here so we can kind of get some good data and then once you've played enough that you feel like you've you've gathered the data you want you just go ahead and hit Escape and then we will minimize the screen here and stop tracing so now that we've completed that it's actually going to load up unreal insights and we'll give it a second here it'll say sometimes it pops up with this weird like uh tree is empty and that's because it's looking at the event aggregation and loading everything in um so this is because of the asset loading option that we sucked if you actually go back to timing insights you'll see your screen like normal so let's go back here and let's take a look so one thing you want to be aware of is there will be outliers especially like when you're first loading in sometimes you'll see spikes sometimes when you're first unloading you'll see it like looks extra low but one thing you want to do is kind of want to for example here I've got this random Spike and let's see if we can figure out you know what's causing the spike um sometimes it's really easy sometimes it can be a little more challenging my hope is that as they develop this tool you get a little bit better information a little bit clearer information on what exactly is going on but as we can see here let's see here we got blueprint time we got something going on here so this is only taking up two milliseconds but this is one of the things I can control with this being part of one of the blueprints that I created so going here and you know most of these things combine don't take up a whole lot of time but you know I might if I created this lower Direction I'm like oh man that takes up a lot of time I can always look in here and see what exactly is taking the most time it looks like it happens four times on a tick um and and it's using almost a millisecond in performance so maybe I could reduce the timer on the or increase the timer on that so it's not happening as often uh that sort of thing I also notice you know there's a lot of physics things going on so I could look into you know what exactly is updating so I see here that it looks like my main character you know their Hull is being updated once in a while unfortunately because it's the main character that's probably okay losing a little performance for something like that and I still want to look into it you know maybe there's ways I can make that more efficient whether it is writing functions in C plus plus or some other option you know there's things that we can do there and I'm going to talk about that in a little bit uh if y'all saw the beginning part there um but yeah so you've got a lot of different things you can look at um the big thing you want to look for is anything that stands out is something that you can truly like do stuff about because it's gonna be some of this that's sort of like you know front end Loop tick like how much of this is actually useful in the current edition you know you can't really tell what you know you can see here that there's some kind of garbage collecting going on um and it might be involving my railguns but you know what does that actually mean in terms of like what is this collect garbage increments actually doing um and at the moment I don't know like without digging into it deeper I'm not sure but there are a lot of times for example with lighting that you can see very easily oh hey this lighting thing's taking up a lot of my performance I should look into this so that is pretty much it for insights and so that kind of leads into our next thing here so one thing you want to do is you want to check for overlapping lighting now that's kind of a weird you know sort of tip but let me go ahead and show you kind of what I'm talking about okay that's gonna sell this um but oh there it is okay um so essentially what's going on here is when I was working on my game I wanted to have lighting coming from all different directions now at the time I didn't know much about the whole Skylight um so what I did is I just added six sunlights all casting shadows and that costed me about 20 to 40 frames per second depending on the situation now that was an issue because two things one I had multiple light sources overlapping now that is worse with Point lights in fact I think with Point lights Unreal Engine by default we'll actually show you an X over top of them if they are overlapping um to say like we are not going to render this out um I think they're exceptions for example baking static lighting I think you're allowed to overlap by six but it's it's still very frowned upon uh because even with baked lighting it can be a little um bit of a performance drain um but simply by just replacing five stationary lights with a single skylight massively changed my performance and the benefit that I get is what the Skylight is now before it was all a plain white light that I was getting like General illumination now I'm getting actually light from the planet Neptune on the station which kind of gives it a little bit more Ambience and then as well my ship's a little bit darker when in the shadows now of course you know you have to be careful and balance that correctly because you don't want to be so dark that players can't see which is something that I'm kind of working through and figuring out you know what's a good balance of that um but overall it's definitely a much better way to handle things much more performant um let's see here so next we're going to talk about actually using C plus plus to handle more complex functions so C plus plus is a bit of a complicated topic so I won't be able to cover everything about it here but just know that there's really great tutorials out there about how to get started on C plus plus um once you get started once you get your project loading building one thing you can do is for anything that you've already done in blueprints the great thing is that you can actually just add C plus functions to those existing blueprints that's one way to really help sort of balance the performance that you get from C Bus Plus with the speed of prototyping you get with blueprints because not everything in blueprints is expensive in fact there are a couple of things that are borderline the identical or very close at least to C plus plus performance but there are some things that are much more expensive so to kind of show an example um we have over here this was a sort of test I did basically the test was to try in three different ways we have a purely C plus option A C plus plus blueprint option and then a purely blueprint option now the C plus version did the best it had under one millisecond response time for the most part it was usually about a millisecond and it was completed the blueprint and C plus plus combined was just a little bit worse but not by much it was about two milliseconds sometimes 2.5 um but overall pretty pretty close close enough that to be it'd be functionally identical um and then the blueprint one um took about 800 milliseconds now this is sort of a worst case scenario for this this is basically um doing the absolute um worst you can for blueprints and that is by using for Loops as well as summing a bunch of different numbers together so it's a lot of heavy number crunching that is really bad for blueprints so the benefit is that we can actually then apply that sort of mindset into actually creating C plus plus functions so as an example here this is an example of C plus plus function I created for my um it's for my player blueprint but essentially what it does is it rotates material um that instance Dynamic materials that my player character has on it so for example in here um I have these vent panels and to rotate them I wanted to be able to rotate them in material so it's less expensive it doesn't require timelines overall it's just better performance wise because it offloads it from the CPU to the GPU so what I've gone ahead and done is basically created a blueprint function that basically just took in some values and then it calls the C plus functions DC plus functions I've actually created inside of here but you can see here I've passed in a bunch of different values and so if we go over here so we've got my this is my library that I sort of have of just different C plus functions that I can use within blueprints so as an example here this is that rotate mids function and what it takes in is an array of those material instance Dynamics it takes in a float it takes in a name which is a scalar parameter value it takes in a rotation minimal value and rotation maximum volume and then with that it basically Loops over all of those mids using that for Loop and then it basically goes if it exists then we're going to actually take the current index which is use using the predicate and then we're going to say you know this map value basically does some really complex math to just sort of rotate it over time to the position that we want it to go to and basically I have it open it or close um so basically what I do is in here if I am opening or closing them is basically what decides which direction they go so they have a rope Min and a rope max value the reason for this is that you're rotating from into this place this allows it to then when it rotates to that place to hold that position that way it's not like when you rotate to the place it then snaps back to the original spot which is what would normally happen if you're not using a Min and max value and so this massively also Saved Me performance because I had some vent systems that were writing previously that were using um timers to actually open up and timers are really expensive now they both are and aren't timers are really expensive when you are using a lot of them um for a lot of offset things things that are very similar but not can't be the exact same timeline so for example here the reason why this one is um like this is because I wanted to be able to rotate these mids offset so one would rotate and then the next and then the next um so the way I can do that is with this time elapsed so if I actually go into the event graph up here I'd have event timer that would start opening the vents and so it would pass in the time elapsed and so with multiple vents I can then go through and say you know is this greater than this time then rotate this one then rotate this one then rotate this one that way um I could rotate them in a specific order that I wanted to so all right um with that we're gonna move on to our last tip here which is tip number five and that is to profile frequently and often now people always say don't profile too soon I actually disagree with that I think that in fact if anything you do want to be careful you do want to understand that when you profile early you're seeing early results and so not to just take them at face value things change over time but to understand that you know when when you're early on if I'd start Prof profiling those skylights I would have noticed much sooner that they were causing a really huge dip in my frame rate but instead I waited till profiling now to go you know I'm seeing that I'm not getting as much fps as I would expect you know what's going on here and I deleted all the skylights I went wait a second I'm getting a huge boost in performance and insights is showing me that I'm getting a boost in performance because these skylights are now no longer overlapping and then I was it was just like a it clicked it was like oh that's because of this that I wasn't aware of because I'm not a lighting person I'm a solo deaf so I was focused more on you know getting it working and making it look pretty so once I learned that I was like okay well I don't want to be pitch black dark you know what do I do do I make less lights do I you know make them not cast Shadows what do I do and that's when I I saw the tip somebody had provided me in the Slackers Discord for Unreal Engine um to actually use a skylight the Skylight would actually work better so I didn't put that in there yep I lost almost no performance and I'm getting this huge um value in the fact that it's presenting some light on the dark sides and it's giving me like this in the color of this actual Planet which is super super nice and it might be hard to tell so I've got a small one over there it's also providing that light as well that's what kind of gives it that sort of tinge on this side um it's almost imperceptible which makes sense because that's a much smaller Moon than you know Neptune um but it is there and so with all that combined that should hopefully helped you to save some performance where you can in-game if you have any more questions or any other tips you'd like to provide to your fellow Unreal Engine developers definitely leave them in comments down below but otherwise good luck good hunting
Info
Channel: Spacemarine658
Views: 8,011
Rating: undefined out of 5
Keywords: Full time game dev, Indie, The reality of going full time dev, UE, UE5, discord memes, discord mod, discord server, game dev, game dev motivation, game dev tips, game developer, game development, game devlog, gamedev, indie game dev, indie game development, indie game devlog, indie playlist, itch.io games, learning game development, optimization, programming, software engineer, unity, unity devlog, unity game development, unreal engine optimization
Id: Z5pKkBNEyc0
Channel Id: undefined
Length: 21min 42sec (1302 seconds)
Published: Fri Aug 18 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.