Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Occlusion culling for 3D side scroller?

Discussion in 'General Graphics' started by martaaay, Nov 30, 2017.

  1. martaaay

    martaaay

    Joined:
    Apr 13, 2009
    Posts:
    136
    Im at the end stages of optimizing a 3D side scroller. I’m seeing culling taking a good chunk of my FPS and am working on that. Since the camera only ever faces 0,0,-1, I’m hoping there is a way I can hook into Unity’s occlusion culling pipeline during bake (or edit the baked data?) to remove more stuff that cannot be seen since the camera never rotated. Any ideas? (I’m hoping this will also massively reduce cull data size!).
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,248
    Have you tried just disabling occlusion culling? By default Unity is using frustum culling which will exclude anything not within the "cone" of the camera's view. Occlusion culling is only useful for hiding stuff that's behind something else.
     
    theANMATOR2b likes this.
  3. martaaay

    martaaay

    Joined:
    Apr 13, 2009
    Posts:
    136
    Thanks for the suggestion! It helped dive me deeper. I found that adding an occlusion area with viewable space ticked to all places where the camera will be (which is a thin box only in the xy plane centered around the z the camera will always be on). This reduced the occlusion calculation time and the final bake size substantially.

    Occlusion culling is still helpful in my game because the player can go underground, in which case I don’t want to show the upper world which can sometimes appear in the frustum.

    Frustum culling is still high on the profile when I run on mobile. What I’m curious about now is if I can reduce this time since I know the frustum is always facing the same direction. I haven’t found a way to disable and write my own (perhaps check against only x and y and maybe within a box since I know the camera is always looking down the z axis). Any ideas how to disable frustum culling altogether or replace it?
     
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,248
    No. There’s no way to disable frustum culling. The best option would be to have some other system that hides sections that you know aren’t visible so frustum culling doesn’t have to do as much work. You may want to look into using Unity’s occlusion portals, or more likely a zone / portal based occlusion asset. Something like SECTR CORE.

    Really anything you know you can’t see should be disabled.