Search Unity

Built-in Dynamic occlusion culling

Discussion in 'Editor & General Support' started by TKDHayk, Jul 31, 2016.

  1. TKDHayk

    TKDHayk

    Joined:
    Dec 22, 2015
    Posts:
    131
    Hi, ladies and gentlemen,

    I'm looking for a way to occlude moving objects when they are not in view. In my case, the moving objects are animated enemies wandering the scene. Using Unity's built in Occlusion culling system, I did manage to get Occlusion culling working for static objects (terrain and static environmental props/trees/rocks). However, the system fails with moving objects.

    My question is, what is the easiest way to implement occlusion culling for moving objects? Do I need to write a system myself or is there a built-in way to achieve it? I have also heard good things about some of the Dynamic OC packages on the asset store, namely this one >> https://www.assetstore.unity3d.com/en/#!/content/6391
    But don't want to pay for it if there is an easy way to do it myself.

    As far as scripting my own occlusion culling system, my idea is to do a raycast from the enemy to the player, and only render the enemy if the ray reaches the player. Other dynamic OC systems do it the other way around, with rays coming out of the camera, but it seems much more efficient to simply have one ray per enemy. This way, I would use unity's built in OC for static objects, and raycasting for moving objects.

    let me know what you think is the best way to proceed.
     
  2. ArachnidAnimal

    ArachnidAnimal

    Joined:
    Mar 3, 2015
    Posts:
    1,839
    Static occluders should be causing dynamic objects to be culled in Unity when you bake occlusion.
    Dynamic objects won't occlude anything using the built in unity OC.
    Unless the enemy is single point in space, your method wouldn't work using a single raycast.
    So you need much more complex solution.

    Could you do all that work yourself for less than $25?
    Unless you make $0.50 per hour, I don't see how.
     
  3. Desutoroiya

    Desutoroiya

    Joined:
    Apr 26, 2016
    Posts:
    12
    I did it with Occlusion Area. Link I would suggest just follow this documentation :)
     
  4. TKDHayk

    TKDHayk

    Joined:
    Dec 22, 2015
    Posts:
    131
    Yup, adding an occlusion area solved the problem. Moving objects are now being occluded. Thanks!
     
  5. aceakle

    aceakle

    Joined:
    Oct 22, 2017
    Posts:
    11
    Another way to achieve occlusion culling on dynamic / moving objects is by using Unity's CullingGroup API. This option will also give you the added benefit of having more control over the objects that your occluding.