Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Objects dissapearing on side of screen

Discussion in 'General Graphics' started by VelocityGames1, Nov 19, 2023.

  1. VelocityGames1

    VelocityGames1

    Joined:
    Jun 4, 2020
    Posts:
    5
    Not sure if this is the right place to post this, but I have an issue in my Unity game where buildings on the side of the screen disappear just before they go off-screen. I am using a virtual camera with cinemachine and have literally played around with every setting and it doesn't change anything, I'll attach a video of whats happening below. Thanks!
    https://youtube.com/shorts/Y8HrLNKk1Hg?feature=share
     
  2. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,571
    Every mesh renderer has a bounding box that is used to determine whether the camera can safely cull the object or not.

    Do you happen to have any code or shaders that change the geometry of the buildings? If so, then the bounding boxes may no longer match what you see on the screen.

    Also, look at the scene view too. Does anything happen there?
     
    VelocityGames1 likes this.
  3. VelocityGames1

    VelocityGames1

    Joined:
    Jun 4, 2020
    Posts:
    5
    I do have a shader graph shader that curves the world depending on how far away it is from the camera. Everything looks normal in the scene view. I'll attach a screenshot of my shader graph. Also thank you for replying this has been frustrating me for weeks. Thank you so much Screenshot 2023-11-23 at 12.29.42 AM.png
     
  4. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,841
    Vertex shaders deform vertices after objects have been culled. So if the bounding box of the object is outside the camera frustum but the vertex shader has taken vertices outside the bounding box, your objects will not be rendered even if the deformed vertices are inside the camera's frustum.

    The solution is simple: expand your bounding boxes to account for any extra deformation. See:
    https://docs.unity3d.com/ScriptReference/Renderer-bounds.html

     
    VelocityGames1 likes this.
  5. VelocityGames1

    VelocityGames1

    Joined:
    Jun 4, 2020
    Posts:
    5
    Thank you so much! Would this script go on each object or just be attached to any static object that stays in the game? Sorry, I'm very much a beginner. Thank you
     
  6. VelocityGames1

    VelocityGames1

    Joined:
    Jun 4, 2020
    Posts:
    5
    I actually just tried both and even tried exaggerating the bounding box multiplier and it didn't seem to affect anything.