I’m a little confused about Unity’s culling system after searching the forums. Is it automatic for objects out of the camera view? I read that high-poly objects like walls in indoor scenes are costly to performance because the whole thing is rendered, in view and out of view. Do most Unity folks use a portal culling script or chop their interiors up into room-sized, bite-sized chunks that can be culled automatically, or do you all use triggers to instantiate/destroy rooms and other objects as you approach them and leave them?
I already use CombineChildren for separate objects sharing the same material, but I’ve been using it on objects that are spaced far apart and out of the camera view. Is that actually more costly if culling is automatic? Thanks in advance for your answers!
Right now the only automatic culling Unity has is view frustum culling. Anything within the view frustum is rendered, whether it’s behind other objects or not. For large objects where some polygons are entirely off-screen, I believe that’s up to OpenGL to decide which polygons to draw. If they’re actually off the screen then they’re not drawn.
I wouldn’t actually instantiate/destroy rooms, unless my levels were extremely large. Turning on/off the renderer would be enough. If your levels consisted entirely of small enclosed areas, narrow twisty corridors, etc., then you could get away with just having a short view frustum and let Unity take care of the culling. Otherwise you’d gain performance by setting up triggers to turn areas on/off.
(You probably already know, but the yellow pyramid-shaped thingy that you get when you click on a camera is the view frustrum. You control the size by setting the field of view and far clip plane.)
Thanks for your answer, Eric. That cleared up a lot of my confusion. I never considered shortening the view frustum. Right now I think it’s rendering all the way to the end of the universe.
terransage, Im pretty sure having the renderer off helps ease the load on the videocard, but theres some physics detection going on if you have mesh and primitive colliders. you can add a collider part way into a scene, when you need it. Then you have to switch off any rigidbodies that might fall through the collider too. I did this in The Oasis and thats how I got so much stuff in the scene. It was always there, just renderer off, collider off, and active=false;
then I used trigger zones to active. Unfortunately some people managed to avoid the triggers somehow and got to the end to find no artwork…trial and error…
AC
I’ll just add that combining objects that are far away can be better or worse on the performance, depending on a lot of factors. If you have a combined mesh, then it will be rendered as soon as any part of it is visible; likewise if there’s a pixel light shining on it then potentially the whole object needs to be redrawn for this pixel light.
I think the best advice would be to combine close objects together.