Occlusion Culling and LOD forUnity Indie

A large house or a car make a picture in your phone to twitch and beautiful shader water - long freeze. If you see some of these objects, everything will be terribly buggy and slow down.

In the Pro version has a very necessary thing called Occlusion Culling. Short - are drawn only objects that fall within the field of view (screenshots under the cut). He looked again at the cost of Pro, scratched his head, offended and left first look, and then write crutches.

Without OcclusionCulling:

With OcclusionCulling:

A good example of what smart people have already thought: Simple LOD Manager. The point is that when approaching the low poly object model (cube) is replaced with high poly (such as detailed building). Of course, use a loop in the Update () is not good, but the idea is worthy of respect.

Satisfies my needs quite a small range of drawing. Of heavy objects - only native trees. Why not draw a heavy object on the approach to it player?

We have a code that is hung on the desired object and has only one parameter - Distance. The code is simple, can be used in the test scenes.

public var distance = 100f;  
private var meshRnd: MeshRenderer;
private var _collider: BoxCollider;
function Awake() 
        meshRnd = gameObject.GetComponentInParent(MeshRenderer);

        _collider = gameObject.AddComponent(BoxCollider);
        _collider.isTrigger = true;
        _collider.size = Vector3(distance, distance, distance);
function OnTriggerEnter (player : Collider) 
        if(player.tag=="Player") meshRnd.enabled = true;

function OnTriggerExit (player: Collider) 
        if(player.tag=="Player") meshRnd.enabled = false;

Catch component MeshRenderer object, which is responsible for drawing the model itself. Create Collider - in this case, box, c edge distance - and make it trigger. If someone - then tagged Player breaks into the collider, it works and renders the model.

Distance to select the most convenient mode Window> Layouts> 2 by 3. Before starting deactivate MeshRenderer the object to which the script hangs.

Good Luck.

All data posted on the site represents accessible information that can be browsed and downloaded for free from the web.



User replies

No replies yet