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.

Mesh32

Quadtree with heightmap

QuadtreeSubdivisionColored

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.

Morphing

Solution for gaps in the edges zoomed

TJunctionsSolid

Gaps formed in change of level of detail

MorphingClose

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

Mesh32

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

QuadtreeSubdivisionColored

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.

4

Final result 1

2

Final result 2