Search Unity

[BUG?] Culling called even if disabled everywhere

Discussion in 'General Graphics' started by FabrizioSpadaro, Nov 14, 2019.

  1. FabrizioSpadaro

    FabrizioSpadaro

    Joined:
    Jul 10, 2012
    Posts:
    287
    Hello everyone,
    As the title suggests, I disabled Occlusion Culling in every camera, but inside the profiler I still see the culling being called, do you guys have any ideas?

     
  2. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    That is probably frustum culling
     
    FabrizioSpadaro likes this.
  3. FabrizioSpadaro

    FabrizioSpadaro

    Joined:
    Jul 10, 2012
    Posts:
    287
    Oh, yeah, that can be it.. do you know any way to disable/inhibit it?
     
  4. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    You should not. Then unity would try to render meshes behind camera also
     
  5. FabrizioSpadaro

    FabrizioSpadaro

    Joined:
    Jul 10, 2012
    Posts:
    287
    The problem is that it's a 2D game so I don't need it at all
     
  6. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,639
    Frustum culling still works in 2D. It will cull anything that is not on the screen. Why do want to disable it? Generally speaking, rendering absolutely everything in the scene will take a lot longer than culling it.
     
  7. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    There's no way to disable frustum culling apart from manually rendering everything using command buffers and not using any built in rendering components.

    If you have a lot of time spent in culling, you may want to look into manually disabling objects outside of the screen view. That'll reduce the culling time as it has fewer objects it needs to cull, but may increase your overall frame time since enabling and disabling objects can be expensive. So you don't want to do this often, and you don't necessarily want to disable a lot of objects at once (it'll create a spike in the CPU time).
     
  8. FabrizioSpadaro

    FabrizioSpadaro

    Joined:
    Jul 10, 2012
    Posts:
    287
    I see, would it be a good idea to subdivide the scene in quads and put all the objects as children of that quads, so I'll just disable enable quads when the player is inside the bb of a quad?
     
  9. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    Yep, that's a valid way to handle it. Though you need to take into account what the screen can see vs just being the player position. You can either have really big bounds for each quad that's roughly the size of the screen, or compare the screen bounds with the quad bounds directly. The later option is nice because it means zooming in and out, as well as ultra wide screen monitors are better supported without needing to change scene data, and what is or isn't in view can be more tightly culled.
     
  10. FabrizioSpadaro

    FabrizioSpadaro

    Joined:
    Jul 10, 2012
    Posts:
    287
    Yeah sure, I was thinking to take the camera FOV into consideration, thanks for the advice!