Welcome to UnityMagic.com

Occlussion Culling and Perfomance Tutorial for Unity 3D

Occlusion Culling Unity 3D

 


Introduction

We are very pleased to introduce a great occlusion system which was developed by Mike Hergaarden. This system was created for the Creative Technology department of University of Twente in the Netherlands. This tutorial and its accompanying projects will help you solve perfomance problems wich you might face during the development of a game or simulation in Unity 3d.

Optimizing Unity games

To optimize the speed of your Unity 3d application the following parameters matter:

  • Rendering performance
  • Script performance
  • Physics performance

Below you will find some quick hints for optimizing your Unity 3d project. These hints can also be found in the tutorial.

 

Rendering performance

Unity manual "Optimizing graphics performance"

Unity's own optimization tips, a must read:Unity3d.com support documentation Optimizing Graphics Performance

 

Combine meshes

Combines meshdata of several meshes that use the same material to greatly reduce drawcalls. Sometimes it's wise to even consider combining textures so that you can make use of combine meshes more effectively. See the Unity Standard Assets for the script.

 

Render statistics window

While the built in render statistics window does not exactly show you your performance bottleneck, it can help you pinpoint it.

See: Unity3d.com support documentation Quality Settings

 

Guideline for Character models

See:Unity3d.com support documentation Modeling Optimized Characters

 

Camera layer culldistance

A handy function to define culling distance per layer (instead of using just the camera far plane setting). You wouldn't need this if you use the culling system developed by Mike Hergaarden though.

See: Unity3d.com support documentation Cameralayer Culling Distances

 

Frustum culling

Per default Unity applies frustum culling for you; it removes all objects that are outside of the camera's view frustum. However, objects that are inside the view frustum but behind other objects (and thus not visible) are still being rendered and cost you performance. This is where Mike's occlusion system can help you boost your FPS.

 

Script performance

Script optimization

A must read: Unity3d.com support documentation Perfomance Optimization

Below are a few additions to Unity's script optimization guidelines:

1. Do not abuse OnGUI or FixedUpdate for non-GUI functions.

Don't use these functions for stuff that could be run in Update instead. Abusing these functions will really cost performance because OnGUI and FixedUpdate will start hogging the application; if they run too often they take up Update()'s time.

2. Unity profiler (Pro only)

Use the profiler to detect bottlenecks: Unity3d.com support documentation Profiler Manual

 

Physics performance

Rigidbody sleeping

Disable physic calculations below a certain velocity.

See: Unity3d.com support documentation Rigidbody Sleeping

 

Solver iteration count

How accurate do you need your physics calculations? The more precise, the heavier the calculations.

See: Unity3d.com support documentation Physicssolver Iteration Count

 

M2H Occlusion culling system

What is this all about?

The M2H Occlusion culling system disables rendering of object that are not visible and therefore greatly reduces draw calls and the verts/tris count. However, the real power behind this tool is the Editorscript for the authoring side. M2H Studios has developed two versions of this system, let's call them M2HCullingManual and M2HCullingAuto. The difference with Auto is that it requires less setup; the system calculates which objects are in the areas. If you need more control you can use manual.

 

How does M2HCullingManual work?

The culling system uses three concepts; the camera culling script, culling areas and culling groups. For every culling area you select which culling groups are visible and, optionally, which are never visible. The culling groups are enabled/disabled(culled) depending on the camera's position. The actual culling is done by enabling/disabling unity render components.

This is just a small part of a great manual writen by Mike Hergaarden of M2H Studios. The complete manual including the project files can be download from M2H Studios website

M2H Game Studio: www.m2h.nl

M2H Occlusion culling system download page: www.m2h.nl/unity On this page you will also find some other great Unity 3d resources.

On last thing, thanks Mike! We are very glad you and M2H Game Studio is willing to share this great resource with the world! It has made our lives a lot less stressfull!