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!
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?
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
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
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
I actually just tried both and even tried exaggerating the bounding box multiplier and it didn’t seem to affect anything.