Boost your games performance! | Godot 4 optimization tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
if you clicked on this video you probably ran into optimization issues on your project or maybe you're just bored well whatever the reason let's talk about optimization the word itself brings horrific thoughts to most people optimization may be a daunting and tedious task but I'm going to help you improve your game's performance with the best optimization methods so now let's get started I usually like classifying optimization as three different categories visual physics and process luckily GoDaddy provides a tool to help you figure out what's eating your performance the most and it's called the profiler if you open the debug tab at the bottom you will find profiler and visual profiler and they're both pretty straightforward you click Start on either one of the profilers and it will tell you what is using the most performance once you figured out what's killing your frames let's find a solution first let's start with optimizing the visual side occlusion calling first up what is calling you usually hear this word a lot when it comes to rendering well let me put it in simple terms for you when something is C it is not rendered when something is not C it's rendered that's all culling is now back to occlusion culling basically occlusion culling is when a mesh is C SL not rendered because there is an object blocking it from the camera in god daddy the way you get occlusion culling is with the uder instance 3D node once you add it and click on it you'll see in the inspector it needs a shape you you can give it a primitive shape like a cube and anything behind the occluder cube shape will be called to give it a more advanced shape you need to click bake occluders at the top and it will give it an occlusion shape of the nodes parent and siblings lods LOD stands for level of detail and it basically decimates a mesh as it gets farther from the camera you can notice that as I get farther away the tree becomes less detailed the number of polygons on the tree get less and less the further away I go from it and go back to normal when I get closer getting lods on a mesh is actually surprisingly simple and GoDaddy by default it's enabled on every mesh but it's weak to make it stronger go to your mesh and find the L bias slider the slider being lower makes the LOD stronger and a higher value just makes the lods weaker visibility range visibility range just makes it so when an object is beyond the given distance from the camera it will be cold SL not rendered you can also use visibility range to make an object too close to the camera be called This is useful for when you have a lot of something spread throughout your scene like trees to enable it go to your mesh and search for visibility range just bring the inth value up and you'll see the mesh gets cold when you are farther than the designated value on the slider to make an object Too Close get cold you just need to in increase the value on the begin slider just be careful to not make the value on the begin slider larger than the value on the end slider or else your PC will explode baked lighting Dynamic lights are designed to be moved around during runtime which means they constantly have to recalculate which can cause a toll on performance instead of using Dynamic lights like omni light 3D or directional light 3D you can use a big light map when you bake a light it does the heavy calculation only once so if you have a static scene then baked light Maps would be the perfect choice and the thing about a baked light map is that since it only has to do the lighting calculation once you can make the lighting even more advanced which will end up giving you better looking and more optimized [Music] lighting minimizing draw calls a draw call is when your CPU has to tell your GPU to render a mesh so if you have many different meshes and your CPU is constantly tell telling your GPU to individually render each mesh I assume you see a problem one solution to this is a multi mesh instance 3D which is basically putting a bunch of meshes into one mesh node and that mesh node needs only one draw call to render in other words instead of multiple draw calls for multiple meshes it's one draw call for multiple meshes that sounds a bit overpowered though what's the catch well since it's basically putting a bunch of meshes in one mesh node the downside is that to render one you have to render all of them so view frustr culling won't work for each individual mesh in your multi mesh so don't put too many things in one multi- mesh and instead chunk your multi meshes now let's move on to optimizing process now usually code in process is extremely lightweight unless you have something very screwed up in your code like a bunch of Loops or if you have a bunch of objects with scripts that have underscore process in them if you look at this script you'll see some crazy for loops and calculations and if I run the game you'll see the frames are much worse and when I deleted it my frames go back to normal when I optimize The Code by having less iterations the frames become good again but if I add a ton of cubes with these scripts on them the frames die again well if you have a loop you can put it in a thread so it doesn't run on the main thread which is the thread that is used for rendering or if you can't put it in a thread one funny method I like to do is to put a timer somewhere in the loop basically the timer makes the loop iterate much slower but it saves your frame rate although it doesn't really work when you have it in process cuz it just creates a memory leak another solution is to make the scripts paused if they are a certain distance away from you I have a cube manager here that calculates the distance between the player and each Cube and if the Cube's too far it pauses the cube or instead just have the cube manager process the code for each Cube so instead of having one process for every Cube you have only one heavy process but what if you tried all that and you are still in well I don't know clean up your coat or something
Info
Channel: Ryan Games
Views: 26,782
Rating: undefined out of 5
Keywords: Godot, Game, Game development, Video game, Godot tutorial, Godot 3D, Godot optimization, optimization, performance, Godot performance, Godot make game run better, Godot lag, Godot optimization 3d, Godot optimize performance, Godot 4, Godot code optimization, Godot engine optimization, Godot 4.0, Game optimization, 3D game optimization, Godot best practices, Godot tips, Godot 4 optimization tips
Id: q1nwCJpjURQ
Channel Id: undefined
Length: 6min 3sec (363 seconds)
Published: Mon Oct 16 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.