Quadtree for terrain generation

This project was about doing some terrain generation via a quadtree and heightmaps.

The quadtree was used to control the level of detail in the terrain. For this I used a simple algorithm that took into account the distance from cameras position to the point of the terrain in the original plane. Each leaf node in the quadtree represents the position and scale of the same plane mesh of 32*32 vertices.


Quadtree with heightmap


Quadtree as a plane

The problem on combining heightmaps with such level of detail techniques is that, in the edges where the precision changes, gaps appear. To solve this, I used the approach explained by Filip Strugar in his paper from July 2010. Explained simply, what it does is offset the position of half the vertices slowly until we reach the same edge layout as the smaller precision. This is done in the GPU, and we need to pass the information of the neighbors precision of the current node.


Solution for gaps in the edges zoomed


Gaps formed in change of level of detail


After this I played around a bit with creating noise rather than loading heightmaps directly.


Perlin noise ridged, pushed towards the 0 of the plane, and inverted. To try to emulate rivers


Various levels of Perlin noise combined

And together with adding this noises for the terrain, I used various textures that blended together depending on the height of the terrain, for having a bit more of a terrain looking terrain. Also, added bluish plane at height 0 that changes alpha depending on the angle to act as water over low areas.


Final result 1


Final result 2