Polygonal Mind
  • Home
  • SERVICES
  • Projects
  • Decentraland
  • Blog
  • Assets
  • / CryptoAvatars

Blog

Optimizing VRChat Worlds: Occlusion Culling

1/21/2021

0 Comments

 
Premise
VRChat is a well known social platform for all those who have VR equipment, and even if you don't have any specific hardware, you can join the party from your standard PC screen too! When you create a scenario, you have to be cautious with texture sizing and data management to make sure you can run your scene, but also the target audience can too! If you fail to democratize hardware requirements then you fail to create a popular VRChat World.
The Mission
Resources
This guide focuses on the Occlusion Culling function of Unity and how to improve the size of the scene by lowering texture sizing, hiding what can't be seen. Also we will talk about occlusion portals, although this scenario doesn't use any as its all outdoors with no enclosed areas.
  • Unity Editor (2018.4.20f1)
Please note that this is VRChat focused but is something Unity Engine related issue.
Optimizing VRChat worlds with Occlusion Culling
#00 What is Occlusion Culling

Occlusion culling is a process which prevents Unity from performing rendering calculations for GameObjects that are completely hidden from view (occluded) by other GameObjects.
Every frame, a camera perform culling operations that examine the Renderers in the Scene and exclude (cull) those that do not need to be drawn. By default, Cameras perform frustum culling, which excludes all Renderers that do not fall within the Camera’s view frustum. However, frustum culling does not check whether a Renderer is occluded by other GameObjects, and so Unity can still waste CPU and GPU time on rendering operations for Renderers that are not visible in the final frame. Occlusion culling stops Unity from performing these wasted operations.

https://docs.unity3d.com/Manual/OcclusionCulling.html
​

This is basically the core knowledge of the whole system. This technique is used to avoid doing the real time calculations of gameObjects that are not in the Camera frustrum. This improves framerate and events performance during runtime.
Occlusion Culling on Unity 3D
#01 How do you apply it to your scene

To begin creating an "occlusion area" you need to check the box "static" or just click on the drop down and toggle "OccluderStatic" and "OccludeeStatic". Another approach is to select the desired gameobjects and toggle option in the Occlusion Window on the Object Panel.
Occlusion Culling on Unity 3D
Occlusion Culling on Unity 3D
This tells the engine to consider the gameObject when calculating the Occlusion Data within its Occlusion Area (Unity considers the whole scene as a single area if you don't configure one prior bake).
Occluders and Occludees
The main difference between these two Occlusion concepts is pretty simple but its important to keep it in mind when building your scene occlusion areas and data.
​
  • An Occluder is an object that can hide another objects
  • An Occludee is an object that can be hidden from view by another object (Occluder). If you uncheck this, the object will be considered differently like if it was on another layer, not being hidden by other meshrenderers.
​
An example of Occludee toggle would be for larger objects like grounds that should be considered separately to ensure its always rendered.
#02 Culling Portals and Culling Areas

Culling Areas are "cube" shaped volumes that "group" all the gameObjects inside of it, being only rendered if the camera is placed inside the same area. This works well if you have multiple enclosed areas, for our case, Occlusion areas didnt make sense as the whole scene is enclosed without visual walls among it.
​
Occlusion Portals are for connecting two Occlusion Areas and so the Camera can render both areas by the Portal region area. The toggle Open option is for allowing or disallowing this conneciton.
More info: https://docs.unity3d.com/2018.4/Documentation/Manual/class-OcclusionArea.html
100 Avatars world in VRChat top view
top view of the 100 Avatars world
Occlusion Culling on Unity 3D
Occlusion Culling on Unity 3D
Occlusion areas and portals
#03 Alternatives to Unity's Occlusion Culling system

The Occlusion system uses a built-in version of Umbra. As any other system, it has its failures and improvements compared to other occlusion system engines. For other projects I personally have worked with Sector, an Asset Package found in the Asset Store that is very helpful and by the time I worked with it it was way better than the Unity's Umbra (more flexible settings as its main selling point).
​
Another thing to keep in mind is the use of shaders with an excess of passes. Each pass is a whole mesh calculation for the material to be rendered and so Materials with more than two passes can be problematic for lower platforms like mobile. I state two as a minimum because transparent materials require two passes, furthermore they require the renderer to render whats behind the mesh rendered with transparency so they are quite the hard limit for low platforms.
Copy of Batch example

Mesh render
1
Apply mat albedo
1
Apply mat transparency
1
Apply light
1

Please keep in mind that "static batching" meshes get combined during runtime by the unity engine and so reduce the "meshrender" batching but keep the mat batching.
#04 Occlusion in the Gauguin Avatar Garden

The whole scene is marked as "Static" as there are no dynamic objects to keep in mind (the water is animated through material [not shader]). This made the Occlusion set up "easy" and not very hard to set the first steps. Keep in mind the size of the Occluder box you want to set, the bigger, the less "accurate" it will be, but at the same time the data will be much smaller. Each project needs its own balance.


In this case for Gauguin we set the size to 1.5, meaning that the smallest "box" packing objects was of 1.5 units (meters) in x/y/z value.


The Smallest Hole float is the setting to tell the camera how big it has to be the "hole" in the mesh to start casting what is behind it. This is specially tricky on elements with small holes or meshes with complicated shapes.
​

The backface value is the value of directionality of a mesh to be rendered. The higher, the more "aggresive" the occluder will be, making the camera not compute meshes that are not facing towards the camera.
Occlusion Culling on Unity 3D
100 Avatars world in VRChat
100 Avatars world in VRChat
100 Avatars world in VRChat
Note that all the "black" shadows are objects that are not getting rendered as their lightbake remains on the mesh that is being rendered. Furthermore you can see the "area" that the camera is in with the correspondent portals. When there is none in scene Unity creates them for you. 
The best workaround is to always do it manually and never let the program do the math for you.
​
For the scene, the ground meshes were kept without the Occludee option as smaller avatars made it through the ground floor due to camera frustrum and its near clip (this cannot be changed as it how it goes in VRChat).
live action of occlusion culling in 100 Avatars world
A live action of how the occlusion is working
#05 cOcclunclusion

You may find Occlusion Culling easy to set up or even unnecessary!
​But the truth is that is a vital piece during the final stages of environment development as is the manager, loader and unloader, of all the visual aspects of the camera, ensuring an smooth experience while mantaining the quality levels desired and keeping hidden from view but not unloaded from scene to ensure fast-charging-fast-hidding.


Also each time you modify a gameObject property like transform or add/remove gameObjects from scene you should rebuild your Occlusion data as those gameObjects are still "baked" in the data.
​

Keep it in mind specially when working with large environments or low-specs platforms.
You are more than welcome to drop any question or your try-out and results!

Join us: https://discord.gg/UDf9cPy

Picture
Kourtin
ENVIRONMENT ARTIST
I purr when you're not looking. I'm passionate about environments and all the techie stuff to make them look rad. Learning and improving everyday to be a better hooman.
Twitter
0 Comments



Leave a Reply.

    Categories

    All
    Decentraland
    Decentraland En Español
    Maya
    Metaverse
    Mixamo
    Morphite
    Substance Painter
    The Sandbox
    Totally Reliable Delivery Service
    Unity 3D
    Updates
    VRChat

    Archives

    February 2021
    January 2021
    December 2020
    October 2020
    August 2020
    July 2020
    June 2020
    May 2020
    April 2020
    March 2020
    February 2020
    December 2019
    October 2019
    September 2019
    August 2019
    June 2019
    May 2019
    February 2019
    January 2019
    December 2018
    November 2018
    October 2018
    September 2016

    Picture
Home
Projects
Assets

Picture
Crypto
Friendly
Picture

Subscribe to get some 💚 in your inbox once in a while.

Follow us and your visit will never be forgotten!
Picture
Picture
Picture

 © 2015-2020 POLYGONAL MIND LTD. ALL RIGHTS RESERVED.
  • Home
  • SERVICES
  • Projects
  • Decentraland
  • Blog
  • Assets
  • / CryptoAvatars