Does a camera render an entire object when it only sees part of it?

Ok, so I’m trying to make a huge seamless world. One way is to make hundreds of “chunks” of terrain in blender and load them as the player nears them, but that would be a pain in the butt to make in blender. I would rather just make a massive terrain model and only have the camera render areas of the model it can see.

So, basically, if I have a huuuuge model, and the camera can see a little area of it, will it try to render all the vertices and materials on the model and lag, or will it just render the vertices and materials it sees.

The answer is yes, and yes, in that order.

That’s a confusing answer since you’d think it’d be one or the other, but it’s not. There’s multiple things that happen when you try to render something, but perhaps the most important is how much the CPU thinks needs to be rendered vs how much the GPU actually renders.

Here’s the simple case with something like a basic box. This is a generalized case and not necessarily exactly how Unity does it.

A box has 6 faces, or 8 vertices and 12 polygons, and this box has a single material across all of them.
The CPU will calculate a simple shape (usually a sphere, but this depends on the engine) that encapsulates the entirety of the box and test the camera’s frustum, the rectangular cone shaped area it can see, against this sphere. If the two intersect, it adds it to a list of things to be rendered and prepares the mesh, the shader, the material, and the texture(s) to be sent to the video card.
GPU receives the data for the box and information about where to render it using the information provided, and tries to render it to the screen.

Here’s where the question gets odd. In the case of a box mesh and a sphere bounds the sphere is much larger than the box itself, so there’s a good chance it’ll get sent to the video card but not be visible. In this case the vertex portion of the shader is run and places the box off screen. At this point the GPU is smart enough to know it does’t have to render anything more.

This is why I said yes to both options, it’ll try to render it, but it won’t necessarily render all of the materials if they don’t appear on screen. However you still paid most of the cost in trying to render it by sending over all of the information.

In the case of a more complex model, those bounds are for the entire mesh, so the CPU is always thinking the entire thing is visible and will upload the needed information for it every time. Note however that the mesh and materials aren’t usually uploaded every frame, after the first time they’re needed they’re sent and cached on the GPU and following draw calls just point at that data with essentially just updated position information… unless you’ve got a really giant mesh and a lot of textures such that it uses more memory than the GPU has which then it does need to send it every time. This is super, super slow.

So, yes, you do need to break up the giant mesh into chunks, otherwise the CPU will treat it as a single object for visibility testing.

1 Like

You might want to consider buying worldmachine because that has features to automatically generate tiled terrain (either as heightmaps or meshes I believe). Using the terrain features of unity seems to be tricky from what I’ve read and experienced, so maybe tiled meshes (possible with LODs) are the way to go for you.

Blender isn’t good at handling terrain related tasks in my opinion.