In my attempt at procedural terrain generation, I’m forced to divide my world into many small terrains with 129x129 heightmap resolution each, because spawning larger terrains at runtime causes a noticable lag.
However, for some reason, having multiple small terrains seems to be a big hit on performance. In the example pictures below I compare a scene of 6x6 terrains with a scene of 12x12. Although the second gives only a slight increase in polygon count and draw calls, the fps is more than halved. Unless it’s related to some kind of camera culling or similar, the reason must be that having multiple terrains causes an overhead by itself.
What’s the reason for this overhead? Any ideas how I can improve the performance?
(This might not be the prefect answer but it gives you a direction to look at)
It’s not the amount of polygons that causes big performance issues it’s the texture looks ups.
If your not fermiler with shaders a texture lookup is what it sounds like. Every time the shader has to look at a texture and read a pixel that has an over head (it has to do this for every pixel on screen).
Saying this I have a question. How many textures are you feeding your shader?
Well, every type of generation is performed by your computer processor, if you generate 12x12 terrains, you’ll have bigger terrains (but less), and if you generate 6x6 terrains, you’ll have smaller terrains (and more). Maybe (for some reason) a single 12x12 terrain costs less memory than 2 6x6 terrains, so generating 12x12 terrains will make the game run “faster”. However this depends on the USER processor, so if the player’s processor is more powerfull than your’s, the game will not lag (or will have less lag). I think there are some changes you can do to improve the performance, such as ajusting the shader and all shadows options (cuz they cause big performance impact) and making each terrain as big as possible.