A large-scale real-world terrain renderer written in Rust using the Bevy game engine.
This project is developed by Kurt Kühnert and contains the reference implementation of my bachelor thesis. This terrain renderer focuses on visualizing large-scale terrains in a seamless, continuous, and efficient manner. The source code was developed as the open-source plugin bevy_terrain for the Bevy game engine.
Additionally, this repository contains the full version of my Bachelor Thesis describing the novel terrain rendering method in great detail. A citable version is also available.
This Video showcases the capabilities and features of this terrain renderer.
The terrain data is taken from the Geoportal Sachsen (GeoSN, dl-de/by-2-0) and the Federal Office of Topography (©swisstopo).
Real-time rendering of large-scale terrains is a difficult problem and remains an active field of research. The massive scale of these landscapes, where the ratio between the size of the terrain and its resolution is spanning multiple orders of magnitude, requires an efficient level of detail strategy. It is crucial that the geometry, as well as the terrain data, are represented seamlessly at varying distances while maintaining a constant visual quality. This thesis investigates common techniques and previous solutions to problems associated with the rendering of height field terrains and discusses their benefits and drawbacks. Subsequently, two solutions to the stated problems are presented, which build and expand upon the state-of-the-art rendering methods. A seamless and efficient mesh representation is achieved by the novel Uniform Distance-Dependent Level of Detail (UDLOD) triangulation method. This fully GPU-based algorithm subdivides a quadtree covering the terrain into small tiles, which can be culled in parallel, and are morphed seamlessly in the vertex shader, resulting in a densely and temporally consistent triangulated mesh. The proposed Chunked Clipmap combines the strengths of both quadtrees and clipmaps to enable efficient out-of-core paging of terrain data. This data structure allows for constant time view-dependent access, graceful degradation if data is unavailable, and supports trilinear and anisotropic filtering. Together these, otherwise independent, techniques enable the rendering of large-scale real-world terrains, which is demonstrated on a dataset encompassing the entire Free State of Saxony at a resolution of one meter, in real-time.
The precompiled binaries for Windows, Linux(Debian), and MacOS are supplied on the right. Simply download and install the latest version.
If a released version is not available for your OS, or you want to experiment with the code, please compile the project from source.
Clone this project:
git clone https://github.com/kurtkuehnert/terrain_renderer
Note: make sure your rust version is up to date (rustup update stable
)
Now compile the terrain renderer, like so:
cargo build --release
Before you can run the terrain renderer you first have to set up the config file and download the terrain data.
Simply modify the config.toml
file found at the root of the repository or bundled with your release.
Here you have to specify in which directory the data for the terrains should be stored.
Therefore edit the terrain_dir
field.
The terrain
field selects which of the different terrain configurations to use.
Each of them will be stored in a subdirectory with the same name.
By default, there are four terrains available: Hartenstein, Hartenstein_large, Saxony, and Uri. Additional parameters control the quality and appearance of the terrain. For more information on the, take a look here.
Note: The Saxony dataset takes up over 100 GB of diskspace and is compiled from 2 TB of source data. Start by trying the Hartenstein terrain first.
Before the terrain can be rendered you first have to download its terrain data. The downloader supports downloading data from the Swiss and Saxon datasets.
For the downloader to work it requires a list urls of the tile data.
The lists for the default terrains can be found in the urls
directory.
Simply copy the appropriate one into the directory of the terrain. (E.g. my_terrain_dir/MyTerrain/my_urls.csv
)
Additionally, the process of generating such a list for any desired terrain is described below.
To download a terrain from the Saxon dataset, provide the tiles by copying their urls from this website: https://www.geodaten.sachsen.de/batch-download-4719.html.
There select the region and the municipality and copy the links by clicking on the blue button.
Then you have to paste all links into a text file (.txt or .csv) and save it inside the subdirectory of the terrain you want to download.
Finally, configure the urls_saxony
field for your terrain in the config file.
Make sure that the side_length
is larger or equal to the maximum amount of tiles in x or y direction.
Note: All DTM and DSM data of the terrain is downloaded automatically as well.
[[terrains]]
name = "Hartenstein"
side_length = 4
urls_saxony = "urls.txt"
terrain_dir
└── Hartenstein
└── urls.txt
The process for terrains from the Swiss dataset is similar. Here you have to specify the dtm and dop data separately. Select individual tiles or entire regions on the following two web pages. https://www.swisstopo.admin.ch/en/geodata/height/alti3d.html for the height data (DTM) and https://www.swisstopo.admin.ch/en/geodata/images/ortho/swissimage10.html for the orthophotos (DOP). Make sure the parameters match the ones in the screenshot below. Then press the blue search button, export all links in the menu below, and download them as a csv file. Finally copy both urls files into the terrains directory.
Note: Swiss DSM data is not supported.
[[terrains]]
name = "Bern"
side_length = 200
urls_saxony = "urls.txt"
terrain_dir
└── Bern
├── urls_dtm.csv
└── urls_dop.csv
With the configuration set up you can now start the download tool.
Note: It may take a while until all data has finished downloading.
./download_tool
or
cargo run --release --package download_tool
Finally, you can visualize the data with the terrain renderer.
Make sure to set the preprocess
flag in the config to true, the first time you view each terrain so that the terrain data can be imported.
Note: It may take a while until all data has been preprocessed.
./saxony_terrain_renderer
or
cargo run --release
These are the controls of the terrain renderer. Use them to fly over the terrain, experiment with the quality settings and enter the different debug views.
-
T
- toggle camera movement -
move the mouse to look around
-
press the arrow keys to move the camera horizontally
-
use
PageUp
andPageDown
to move the camera vertically -
use
Home
andEnd
to increase/decrease the camera's movement speed -
V
- toggle DTM/DSM -
W
- toggle wireframe view -
P
- toggle tile view -
L
- toggle lod view -
U
- toggle uv view -
C
- toggle node view -
D
- toggle mesh morph -
A
- toggle albedo -
B
- toggle base color black / white -
S
- toggle lighting -
G
- toggle filtering bilinear / trilinear + anisotropic -
F
- freeze frustum culling -
H
- decrease tile scale -
J
- increase tile scale -
N
- decrease grid size -
E
- increase grid size -
I
- decrease view distance -
O
- increase view distance -
Z
- toggle sun rotation -
X
- decrease the sun's period duration -
Q
- increase the sun's period duration
Saxony Terrain Renderer is dual-licensed under either
- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
at your option.
The Thesis.pdf is excluded from both of these and is licensed under the CC BY 4.0 license instead.