Use Occlusion Culling like a PRO | unity advanced tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
you asked for it you got it welcome to the occlusion calling advanced tutorial occluder versus oculus d when we select an object we will see the occluder static and occlude static on the occlusion calling window anything marked with excluder will hide anything behind it we can use it for wall rocks and big objects for example the oculud option means that it can be hidden by other objects in the scene other occluders the default is using both an occluder and oculus d on your objects but you might be asking yourself why would i make something only occlude for this we have two examples first of all things like trees won't hide anything behind it that means that all the occluder data that will be baked by the tree won't be used in the actual game the same goes for the net that will have a lot of holes in it and therefore won't be a good occluder fyi the occlusion calling takes into account transparency so if you have transparent things it won't take them to account so don't put them at the clutters either now let's talk about some baking variables okay so i made a basic scene with few objects when we bake using the default values and go to visualization we will see that some objects are actually blocking things and some don't to fix this we'll change the smallest occluder size to one that means that every object larger than one meter will be taken into account when we bake the scene the next variable we'll use is the smallest hole every hole in our mesh larger than this size will be rendered as a hole and every hole smaller than this size will be filled in that means that we can't look through it this variable main purpose is to compensate the fact that most renderers have unintentional holes unity recommends putting the values between zero points to a five and 0.5 just play with it and see what fits you in this example i changed it to 0.5 so most of my fans is blocking the view if you have small holes like this you might want to change it to enable the players to look through the holes the last variable we can change is the blackface threshold basically what it does is removing data and lowering the quality of the data of the baking to lower the occlusion data size most of the things it removes is the inside of the object and things that you don't normally see in your scene like the inside of the mountain for example that way it can lower your data size without actually hurting your game if you are changing this play with it and test it because sometimes it makes artifacts that you don't want in your scene and have problems so just be careful some other things you need to know if we want to have a general idea about what our scene is going to look like in your scene change the scene draw mode to overdraw now we can see what object is gonna be behind what what's gonna be hidden what's gonna be shown and maybe find something we didn't think about to fix it back change the draw mode to standout another thing we need to know is how to clear our data we can just press clear and it will clear all our baking data i personally don't think it's necessary because when you bake it overwrites all the other baked data you have so you don't need to clear it before you bake again now let's go to visualization we will see that we have a new window in our scene view camera volumes show where the places that we're gonna render in the occlusion calling for this example i just put few blocks on the side to make the area bigger so it will include more but later we will learn how to do this properly if we are not any kind of volume we won't see the visibility lines the lines that make us see what object is blocking what last one is portals and we will see how to use them in a second and an extra bonus tip we can actually use the camera settings to change our closing calling the easiest way is changing the clipping planes that way only close things will be rendered you might see other games having fogs and things like this i will link tutorial to how to make a fog so you can just make the camera laying closer to you and put a fog around it that way you don't have to render a lot of things in your scene in the same time let's talk about dynamic objects one of the easiest things to do in occlusion calling is dynamic occlusion in the mesh renderer in the additional settings you have dynamic occlusion setting by default it will be set to true that means you can move it around and it will be hidden by any static occluder we don't have dynamic occluder but we have something pretty similar let's talk about portals here we have a scene with the basic door when the door is closed we want it to block the view but when it's open we want to see through it and as you can see enabling and disable it don't change the baking data because it's static baking to make the portal add the occlusion portal component the occlusion portal have very basic variable the center the side of the portal just like a collider would be aware that the normally set to default so you need to change it when you put it into the object and the most important one the open variable as you can probably guess when it's true the portal is open so you can fit through it and when it's false you can see through it because it's close you can also change it through a script by getting the component and changing the open value before we go into the last part i just want to say i broke my head for a week trying to make this tutorial and understand everything deeply so i want to invite you to my discord channel because if you have any problem and there is anything you don't understand perfectly just ask me there and i will answer you as fast as possible because i broke my head of it and you shouldn't too and last for this tutorial occlusion areas to start we'll create an empty game object to hold the area press add component and end the occlusion area component move the area and change its size using the variables or the handles don't forget to bake and you have your occlusion area set up but what is an occlusion area the occlusion area have two main purposes the first one is to have high recollision precision in the area if you are making an mmorpg and don't then you would want to put an occlusion area on the main base when everybody else spawn and not in the middle of the forest where nobody usually is unity's official advice is to put the area in the scene where the camera is most likely to be located at runtime the second useful thing i found and this is not in the unity documentations it will create volumes where you put the area otherwise volumes will be created only next to occluders and you won't see the visibility lines unless you are very close to them as you can see in this example and if you remember previously i did add some objects because i had problems with ability lines so evolution area is the actually right way to do this if you like this video don't forget to like and subscribe and you might like this video about optimizing sprites and you might want to make your occlusion calling look better by adding a fog hope you enjoyed this video see you next time bye
Info
Channel: Nerd Head
Views: 46,317
Rating: undefined out of 5
Keywords: Unity, Programming, Unity3D, Custom occlusion culling, occlusion culling, 3d unity, 3d unity tutorial, c#, culling, game optimization unity, games tutorials, how to, occlusion, occlusion culling unity, Optimization, performance, tutorial, Unity Culling, unity developper, Unity FrameRate, unity game engine, unity for games, unity occlusion, Unity Occlusion Culling, optimisation, unity optimization, Unity Performance, unity tutorial, Unity tutorials, Unity3D FPS, FPS, better, Area, Portal
Id: hv2CUi2eeBY
Channel Id: undefined
Length: 6min 53sec (413 seconds)
Published: Wed Apr 27 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.