Any tips for optimizing terrain?

Hi everyone, I was working on a platformer where essentially most of the action takes place high up on small platforms, while I have used terrain to add a background.

Now I have noticed that terrain uses a lot of resources, and I need it to be procedurally instantiated every time player has moved certain distance as the game is supposed to run infinitely ( tried moving the terrain along with the player by updating the z axis in update function but moving the whole terrain in every single frame slowed the game down). So I have to assume that even instantiating the terrain will come at some costs, so can you guys recommend any tips to make the terrain as light as possible given that the ONLY use of terrain is as a background and player doesn’t have to even touch it. Any other approaches are also welcome, one that I had in mind was if somehow the entire scene could be turned into a skybox, not too sure how I can do that.

On a seperate note, does mobile support the depth of field and fog scripts in Main Camera? because that is the targeted platform.

Thanks in advance :slight_smile:

If the terrain is only a background, why are you using a terrain as opposed to a normal non-terrain mesh?

1 Like

show and render the terrain to a skybox, hide the terrain, and every time player has moved certain distance, show and render the terrain to a skybox and hide it again, but still, you will get some noticeable hiccup from that I guess

Good question :stuck_out_tongue: main reason was ease. Terrain is simply too easy to use. But moreover is there a significant difference in rendering of terrain and mesh?

Well regular meshes are much cheaper because they don’t have to tessellate on the fly. But more importantly, you can optimize the mesh for your particular view distance. You’re paying a huge overhead to have adaptive definition, but it sounds like you don’t need it. With a mesh, you can use poly crunching algorithms to reduce geometry without loosing definition. The Unity terrain system does perfect quads indiscriminately, so it requires a lot of points to get definition. Something like Meshlab’s Quadric Edge Collapse can get your polycount sometimes to 3% of what it was with no visible change, all while preserving UVs. Every software has a version of this these days, Blender has the optimize modifier, Zbrush has decimation master, etc. I actually use all meshes for my game, even for the stuff the player walks on.