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. Dismiss Notice

Frustum Culling by default?

Discussion in 'iOS and tvOS' started by mgeorgoulopoulos, May 7, 2010.

  1. mgeorgoulopoulos

    mgeorgoulopoulos

    Joined:
    Aug 24, 2009
    Posts:
    66
    I don't know if this is a Unity iPhone specific question, but, is frustum culling on objects enabled by default? In the top viewport, I see that my items which are behind my camera or out of view are still rendered.

    I did a manual culling with TestPlanesAABB, and I got rid of them. Shouldn't unity automatically cull hidden - from - view objects?

    PS: Does iPhone 3G and the first iPod touch have multitexturing in single pass?

    Thanks :)
     
  2. kenlem

    kenlem

    Joined:
    Oct 16, 2008
    Posts:
    1,630
    I believe that the behavior is somewhat different in the editor. Since you're looking at the scene from the top down view as well as the game view, the objects outside the camera frustum needs to be rendered if they are included in the top down view.

    Hope that's right and it makes some sort of sense.
     
  3. mgeorgoulopoulos

    mgeorgoulopoulos

    Joined:
    Aug 24, 2009
    Posts:
    66
    Yep that's what I thought as welll, but on iPhone performance was horrible, so I assume that frustum culling wasn't happening. I enabled manual culling, and all went well.

    Not that I mind, I prefer having control over things, but I just think this should be clarified.
     
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,400
    Unity does automatically cull objects not in the view frustum. Adding your own culling will only add more overhead.

    --Eric
     
  5. mgeorgoulopoulos

    mgeorgoulopoulos

    Joined:
    Aug 24, 2009
    Posts:
    66
    Strange, I saw a big performance gain by culling them.
     
    araz01 likes this.
  6. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    then you potentially didn't cull it (renderer disable) but disabled the GO completely (and thus disable the simulation on it) I would guess
     
  7. mgeorgoulopoulos

    mgeorgoulopoulos

    Joined:
    Aug 24, 2009
    Posts:
    66
    actually what I did when the object bounds were out of the frustum, I set gameObject.renderer.enabled = false.

    I was thinking that this is what unity does on the inside, with the difference that I couldnt see my objects after my manual cull.
     
  8. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,400
    That's exactly what Unity does by itself; you can see this in the game view stats as the draw calls go down when objects are no longer in view and aren't rendered any more. You won't get this effect in the editor scene view window, and thus won't get any performance benefits in the editor (except if you have the game view maximized, I suppose), but the only thing that actually matters is performance on the device itself.

    --Eric
     
    Nexer8 likes this.
  9. mgeorgoulopoulos

    mgeorgoulopoulos

    Joined:
    Aug 24, 2009
    Posts:
    66
    Yep after further testing, it's what you'd said of course.
    Thanks a lot for pointing it out!
     
  10. boylec

    boylec

    Joined:
    May 28, 2015
    Posts:
    4
    Actually the renderer is not disabled... it might be getting culled but it is not disabled. I checked, because I was attempting to keep rendering an object when off screen (due to a shader I wrote), and I found that the actual renderer was still enabled when my sprite was off screen although it wasn't drawing obviously.
     
  11. Dabartos

    Dabartos

    Joined:
    May 26, 2016
    Posts:
    32
    I'll grave dig this up, can someone clear it up for me?
     
  12. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    1,121
    Unity knows not to render objects that lie outside of the frustum. But it doesn't do this by literally disabling the Renderer component. It's more likely that they handle this internally engine side, where some culling code will know to omit the frustum culled Renderer from a list of renderers that need to be rendered.

    So the end result is the objects out of the view frustum do get culled when rendering, but you yourself wouldn't be able to confirm this just by checking if the renderer was enabled or not. It'll always say that it is enabled (renderer.enabled will be true) whether it is being culled or not.
     
    Dabartos likes this.
  13. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    As far as I know it's the same threaded API Culling Groups uses, so it'll go through Umbra and so forth. I'm sure @superpig has the facts.
     
    Dabartos likes this.
  14. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,627
    I'm so confused with culling lol.
    If scene view isn't suppose to show frustum culling then why do they show a screen shot in the documents of it working?

    https://docs.unity3d.com/Manual/OcclusionCulling.html

    Edit:
    Oh i see now. I need the Occlusion culling window open to see it culling in scene view.
    Then why is everyone in this thread saying you can't see it in scene view then?
     
    Novack likes this.
  15. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Don't worry about it. It's the internet and everyone is looking at a problem through their own lens. If you grokk, you grokk, grokk?
     
    Shadowing likes this.
  16. eovento

    eovento

    Joined:
    Feb 22, 2018
    Posts:
    38
    It's because this thread was about Frustum Culling, and you are talking about Occlusion Culling. ;)
     
    szymongsetapp likes this.
  17. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,627
    No I was talking about frustum calling. I think you thought I was talking about Occlusion calling because the link I pasted is to Occlusion calling. But on that link it talks about both calling and how you can show frustum calling in the editor.
     
    LaneFox likes this.
  18. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,384
    Frustum Culling always occurs, but you cannot look at things to confirm that you cannot see them.

    The Editor will visualize exact culling, but under the label of "Occlusion Culling". This will include the automatic Frustum Culling, but you must satisfy the parameters of actually visualizing Occlusion Culling in order to visualize culling of any kind in the Editor.

    Therefore, you cannot visualize Frustum Culling without using Occlusion Culling because no one thought to separate visualization of the two. It is purely coincidental that @Shadowing saw both since he already had baked occlusion culling.

    Open your scene, make a static object, bake occlusion culling data and you will see exact culling occur in the scene view.
     
    Last edited: Jul 20, 2020
    imDanOush, itsmars and Iggy101 like this.
  19. Hexican

    Hexican

    Joined:
    Aug 2, 2022
    Posts:
    2
    What I occlude from this thread is that if I don't cull it immediately from my eyes and mind, it's gonna cull my mind without me even seeing it. :po_O