Very Large Scale Terrain (Patreon)
Downloads
Content
As of this post, you're now up to date with my terrain experiments! The video above shows a 128x128km region of terrain rendered with a new level-of-detail (LOD) system that lets us have a much larger render distance.
This LOD system works by rendering multiple copies of the terrain, where each subsequent copy is composed of larger chunks. In the picture below, red represents the first LOD (smallest chunks), green represents LOD 1 and blue represents LOD 2 (largest chunks).
The trick is that each chunk contains the same amount of triangles! I've doubled the size of the chunks in the screenshot below so it's clearer to see the triangles:
From the player's point of view, the distant terrain is so far away that they can't tell it's using less triangles.
LOD Blending
Since multiple copies of the terrain are being rendered, we need to ensure that we can't see the low-quality terrain close up. To achieve this, each LOD sinks when it gets close to the player:
As an optimisation, chunks are hidden when they've fully sunk. There's no point rendering what we can't see!
Lots of LODs
Since each LOD contains the same amount of chunks - and each chunk contains the same amount of triangles - each LOD takes the same amount of time to render.
On my RTX 3070 GPU, each LOD takes 0.06ms to render, meaning the full terrain can be rendered in 0.5ms.
With 8 LODs, we can render a 128x128km region of terrain:
From a birds-eye view you can see the chunks near the camera (center of the screen) have more detail, as they contain more triangles.
From the player's point of view it looks like this:
Improvements
If you watch the video at the top of this post again, when the camera moves you can clearly see where one LOD ends and the next starts. This is because:
- The camera is up so high and is moving so quick
- There are no trees/vegetation to hide the seams
- The terrain textures are simple
- The terrain generation algorithm doesn't scale nicely in each LOD, for example far-away LODs have much longer beaches
These are all things I'd like to improve on, but for now I'm over the moon that I can render far-away terrain just as quickly as close-up terrain. In the high-resolution video you can also see that there are now long-distance shadows over the entire map!