A downloadable tool

I wrote 4 terrain mesh optimization algorithms in Vulkan/C++. Some of them are used in commercial games.

All of them are implemented mostly on the GPU using compute shaders.

1. Brute Force (Not Used in Commercial Games)

I added this one to prove a point :D

The heightmap is divided into multiple chunks of size 128x128, which are tessellated based on the distance from the camera.

When you run this method, the app will freeze because there is no storage optimization on the texture. It loads the full 16K in memory.

2. QuadTree (Used in Far Cry 5)

This method is introduced in the talk linked below. It is fully implemented using compute shaders.


Terrain Rendering in Far Cry 5 (GDC Talk)

3. ClipMaps

This is a simple storage optimization method. I store different zoom levels of the heightmap in 1024x1024 textures.

GPU Gems 2 - Clipmaps Chapter

4. Vertical Error Clipmaps

This method splits the clipmap into 16x16 patches and computes the vertical error of each patch. 

The error is computed using compute shaders, and the results are stored in a vertical error map for each clipmap (64x64). This map is then used for tessellating the terrain in the control shader.

The flatter the terrain, less triangles are tessellated.

Example of clipmaps (red) and their vertical error maps:



Vertical Error Clipmaps (Book Preview)
GDC 2014 - Gollent Talk

Source Code

The full source code is available here: https://github.com/Catalin142/Terrain

Originally, this project was intended to be a terrain generation tool. If you check the Git history, you will find shaders for generating the heightmap, rendering textures using triplanar mapping (based on slope), and texture bombing.

Video Explanation

If you want a full explanation of the concepts, check out my YouTube video:

(Sorry for the mic quality, I improved it in later videos :D)

Controls

  • W, A, S, D - Move
  • E, Q - Up, Down
  • Up, Down, Left, Right Arrows - Rotate Camera
  • Space - Sprint

Updated 15 days ago
Published 17 days ago
StatusReleased
CategoryTool
AuthorPopa Catalin

Download

Download
Terrain.rar 337 MB

Leave a comment

Log in with itch.io to leave a comment.