Lets Look At | Godot 4 Occlusion Culling

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys this is mitch with fine point cgi and today we're going to talk about occlusion calling in godot 4.0 this is a really cool feature that's really going to help step godot forward in terms of being a good 3d engine so the first question is what is occlusion calling well occlusion calling is calling out objects that the camera can't see so culling means to hide or to disappear objects that the computer or i guess the user cannot see and the reason why that's great and why that is helpful is so think of it kind of like if you were in a room you wouldn't want to render anything outside of that room unless the user could see it because it's wasting rendering cycles so that saves a bunch of render time and a bunch of gpu time and it helps keep your game performance now godot has two major ways of calling the first one is called frustum calling and that is on at all times so it's just there and it just runs in the background for you making your game perform really well and what that is is it is calling any objects or removing any objects that are not in camera view so if you take a look at this picture here you can see that all this is where the camera can see so the uh lines is where the camera can see and then this little squiggled out area here is the actual camera what the camera can't see and what gets called out so none of this stuff gets rendered saving your system's resources now the other major calling type is called occlusion culling and occlusion calling uses rays that the camera shoots out think of a kind of like ray casting from the camera and it determines if things are being touched if it can see so like for instance if it would if it would uh launch out a ray it would see the left box and the right box but it would not see the two boxes behind this one box here and because the camera can't see it it would hide those boxes from being rendered saving gpu cycles so that's basically what occlusion calling is and that's the two major ways occlusion calling is in godot 4.0 currently now in 3.3 we have frustrum calling and portal calling and portal calling is different and i went through that in my portal earned one of my godot tutorials prior where i talked about godot getting occlusion calling and i think that method will get ported over here so i'll cover that when that happens but as of right now that's the two ways that we can do occlusion calling in godot is frustrum calling and occlusion calling so now that we understand what both types of calling is let's talk about how it works inside of godot and how well it works inside of godot okay so i'm sitting here inside of cadeau and you can see here this is a scene uh provided by unreal engine i actually exported this out using my uh method i have for the uh export to unreal engine tutorial i use that exact method to export this out for testing so if you guys want to go check that out but this scene is really detailed and there's a lot going on right and you can see my frame time is about 118 fps and my gpu times about eight milliseconds or so and this is a prime candidate for occlusion culling if i go up and i kind of speed it up you can see there are objects behind the world you can see all of these objects look at that all of this is being rendered while godot is running so if i come down here all of this is still being rendered even though i can't see it when i go like this i can't see it but it's all still being rendered so what can we do about that right well we can turn on occlusion calling now in godot you have to go up to your project project settings come over here hit advanced settings and then scroll all the way down to rendering and underneath rendering you will see occlusion calling so go ahead and click on that and then you will see there's occluse rays per thread which is the number of rays that your camera is going to shoot out to determine if something is going to be occlusion called and then you have bvh build quality which is kind of like if you think about um cubes right what they do when you build your occlusion calling is you're actually dividing the world up into these cubes and basically it's uh determining what cubes the uh objects are in and it determines if an object is being seen or not by the camera i know it's kind of weird but that's basically how it works and then we have use occlusion calling which in this case is off so i'm going to go ahead and turn it on and i'm going to hit close you'll see that my frame rate has not changed it is still 120 fps we will right click on our node and add in a child node and we actually received a new node and it's under node 3d and then occlusion instance 3d so if we go ahead and double click on that and bring that in you'll see that again nothing has changed but if i come over to occluder you can see that that's empty right now how do we add one well if we come up to bake occluders we can click on that and then go ahead and name our occluder bake and in my case i'm just going to call it test so we'll go ahead and hit save and you'll see that it's going to sit there and think about it for a minute and it just finished so suddenly you'll see well hold on a minute our fps went down right and our gpu time went up why is that well the reason why it suddenly reduced our frame rate is because of all the stuff it's rendering on the screen to show you that the occlusion calling has baked if we actually come up here and we click on the three little dots and we shut off gizmos you'll see that our frame rate suddenly jumps back up right so that's something just to keep in mind is baking occlusion calling doesn't actually slow you down it can slow you down but generally speaking if your scene is large it's going to save you a lot of time so if i shut off occlusion calling you'll see the fps drops by a good 20 fps but if i turn it back on you'll see that the fps jumps up to 40 fps which is awesome that's a huge boost to performance for godot in 3d now to give you guys a good example of what it does let's go ahead and shut off occlusion calling come up here to the three dots come down to what's called display overdraw and click on it so you can see all of the stuff that godot is rendering right now now if i come up to this little eye here and i toggle visibility you'll see that suddenly it just hid a bunch of those objects that we had previously so if i turn it on or i guess shut it off you can see look at that there's just so many objects and then if we go ahead and click on it suddenly most of those objects go away and if we go back to display normal you'll see our fps goes back to about 140 fps so that's some of the coolest stuff about occlusion calling is it really will help us with performance and you can see like if i rotate the camera how the performance just gets better and better the less objects that you see and if i were to shut off my occlusion instance you'll see that it does generally give us a better performing game see i'm getting 180s i shut that off i'm getting into the 160s so it really is just free performance for your game so i definitely suggest you try it and see what if it works out for you guys now there is some caveats here if your scene is tiny and you don't have very many objects in it occlusion calling may take more cpu time than you would gain on the gpu if that makes sense so that's just something to keep in mind and make sure that you turn on these two little um monitors here to help you out with determining if it's actually worth it which you can turn those on by the way right here if you turn on view information and frame time that will definitely help you with keeping track of what your fps is in your game so let's go down into the bake section here where it says mask here now this mask is what layers it bakes to determine if an object is visible so if you actually go into take a look at an object here so if i add in a node i add in a mesh and i go ahead and add in a box mesh right here i can drag this over here and let's just put it underneath the floor right so if we were to bake our occlusion calling which automatically should handle this i think so i should be able to go right into display overdraw and you can see it's gone oh i think godot just crashed on me yep good oh just crashed on me look at so that's good news so i'm going to reload and i'll be right back okay so godot crashed and corrupted my scene so unfortunately i don't have what i was originally going to show you so i guess i'll just kind of show you and we'll go from there so if i add in a multi-mesh instance and i go ahead and add in a plane here actually i think it's there they actually have a a plane here and then i will scale this up and then i'm going to control oop don't say control duplicate and i'm going to change this over to a cube mesh here or box mesh right here and i'm going to make this smaller something like this and i'll pull this down below and i'm gonna move this into layer two not layer one and then i'm gonna right click add in a occluder and i will go ahead and bake my occluder and it says i need to save my scene so we'll just call this tutorial scene and i'm going to go ahead and bake my occluders and we will save so what you will see is if i bake my occluders and i go to display overdraw oh it's not being drawn okay it's because my gizmos are on there we go so you can see how it's not being drawn right now if i move if i go to occluder instance and then i go to bake and i shut off mass 2 and i bake well it looks like masking doesn't seem to be working in this build of godot so i'm going to go ahead and bug one of the developers and see what is going on but the question is what do you guys think about this new feature do you think that it's worth having in godot do you guys think it's useful let me know in the comments below but that's all i have for you guys today so if you like this video go ahead and hit that like button hey you know if you dislike this video go and hit that dislike button because i'm here to make content for you guys this video was a viewer suggestion so as always i take your suggestions very seriously if you have any suggestions go ahead and throw them in the comments below and i'd be more than happy to add them to my list of future videos but that's all i have for you guys today so thank you so much again for watching and i will see you all next time thanks [Music]
Info
Channel: FinePointCGI
Views: 2,945
Rating: undefined out of 5
Keywords: godot 4, godot, occlusion culling, godot engine, godot occlusion culling, occlusion, occlussion culling, culling, godot tutorial, godot 4 news, light occlusion, occlusion queries, godot shooting game, godot light occluder, light occluder godot, godot light occluder2d, godot light occluder 2d, godot 3.4, 3d games in godot, godot shading language, godot lighting tutorial, godot engine 2d, Lets Look At | Godot 4 Occlusion Culling
Id: lsoUQOpd3Yk
Channel Id: undefined
Length: 13min 0sec (780 seconds)
Published: Sat Sep 18 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.