Search Unity

Objects getting culled in camera view

Discussion in 'General Graphics' started by bug5532, Jul 30, 2019.

  1. bug5532

    bug5532

    Joined:
    Aug 16, 2011
    Posts:
    307
    So I have a weird bug I can't work out. Some of my objects are getting culled (like the renderer has been turned off) whilst still in the cameras view.
    Any idea what could cause this? I've tried changing to the default shader and it still does it.
    Just to add it's not a clippling issue, as the entire object disapears at once.
    The below image shows the view in the editor window and game window, see how the top wall parts are missing.
    upload_2019-7-30_11-19-21.png
     
    Last edited: Jul 30, 2019
    tanmaykulkarni and peopleUnity like this.
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    Do you have Occlusion Culling enabled on the camera? If you do, and turning it off causes them to re-appear, it likely means you have old occlusion data and need to rebake it.
    https://docs.unity3d.com/Manual/OcclusionCulling.html

    If Occlusion Culling is not enabled, or toggling it on or off has no effect, then there's some bug with the mesh's bounds. I'm not sure how you're making your meshes, but if you're importing them from an external file (like .fbx or .blend) then Unity should be calculate the correct bounds for you. If you're generating your meshes in the editor, then it's likely you've simply skipped that part and the objects are being hidden as soon as their pivot point goes off screen. You can either manually set the bounds, or use the built in helper function to automatically calculate them when they're generated (or after the fact if you forgot to do it the first time, just remember to save those changes if they're being saved as assets).
    https://docs.unity3d.com/ScriptReference/Mesh.RecalculateBounds.html
     
  3. bug5532

    bug5532

    Joined:
    Aug 16, 2011
    Posts:
    307
    Thank you so much! this was driving me mad!

    We are using Foundry's ModoBridge to import strait into unity from Modo. I guess they didn't Recalculate bounds! I'll let them know.
    Thanks again!