By: Grover Soria
Unity is a very good 2D and 3D video game development engine, which also allows us to develop for either Android or IOs mobile devices. But one of the problems while developing a game or a virtual walk for mobile devices is performance, especially when using large scenes or when using huge amount of objects. To solve this kind of problem Unity offers a tool called Occlusion Culling.
Occlusion Culling is a tool that disables the objects rendering when they are not being viewed by the camera, including those being placed behind other objects.
To activate this feature we go to the Windows tab and select the Occlusion Culling option.
Then the Occlusion Culling window will appear, in some cases it will appear in the middle of the screen in other cases it will be displayed on the right menu, we can place it where it is more comfortable to us.
Now we have to enable the Static option for the scene objects.
We must emphasize that this option should be enabled for all of the objects in the scene that doesn’t have any kind of animation or movement.
A trick to enable the static option in a faster way for all of the objects in the scene is to group them inside of an empty object and enable its static option, this way Unity will ask if we want to enable it for all of the objects contained inside.
Now we have to enable the main camera static option.
Finally we return to the Occlusion Culling tab and we press the Bake button.
The Computing Occlusion process will begin and its duration will depend on the amount of objects and the size of the scene you are working with.
This process will fill the whole scene with an array of blue boxes and you can see them in the scene by changing the view angle while the process is running.
Once the process is finished, we will observe the Occlusion Culling effect, it will only display the objects in the camera view, to do this we have to select the Visualization option in the Occlusion Culling tab.
Now you only have to rotate the main camera inside the scene to be able to observe the Occlusion Culling effect.
Remember that there are different methods and tools that enable us to optimize our applications in Unity3D. The Culling occlusion is one of these tools, it is simple but it let us optimize the performance of large scenes with many objects.
If you have any experience, doubt or suggestions please write us down below.