Occlusion Culling
Unia uses GPU occlusion culling to avoid rendering objects completely hidden behind other geometry. Large static meshes such as walls, buildings and cliffs make good occluders.
Enabling occlusion
Select a static mesh and enable Occluder in the Edit panel, or register one from code:
world.addOccluder(object);
To remove it:
world.removeOccluder(object);
Meshes can also be marked before they are added to the world:
object.occluder = true;
world.add(object);
Occluders are static. Their full geometry and world transform are copied when registered, so use simple, low-poly meshes. Skinned meshes are not supported. If an occluder moves or changes geometry, remove and register it again.
The depth pass is double-sided and ignores materials, textures and transparency. An object is culled only when its entire projected bounding box is covered. Its nearest point must also be at least one metre behind the occluder, which reduces visible popping. Results may take one frame to affect geometry streaming.
Debugging
Display the occluder depth texture from the developer console:
occlusionDebug.showDepth = true;
Optional debug settings:
occlusionDebug.enabled = true; // Log visibility statistics
occlusionDebug.depthPower = 1; // Show raw depth
occlusionDebug.depthSize = 320; // Overlay size in pixels