Skip to content

SuperTerrain+: A real-time procedural 3D infinite terrain engine with geographical features and photorealistic rendering.

License

Notifications You must be signed in to change notification settings

stephen-hqxu/superterrainplus

Repository files navigation

SuperTerrain+ Project Logo

GitHub Releases GitHub License 3rd-Party License Project Roadmap Documentation

👀 Overview

Procedural content generation is one of the most popular topics in computer graphics and allows us to generate data using the power of algorithms and minimise efforts spent on editing.

SuperTerrain+ is a built-from-scratch procedural terrain engine and real-time renderer started as my personal project in July, 2020 and later become my undergraduate dissertation project. As of current I am using it as a low-level procedural generation and rendering framework for my PhD research.

SuperTerrain+ provides a low-overhead, extendible and flexible interface, demonstrates application of modern programming and rendering techniques; with the help of extensive in-source documentations, this is also a great place for learning.

💡 Main Features

Procedural heightfield infinite terrain

  • Improved simplex noise
  • Hardware tessellation
  • Continuous level-of-detail
  • Multi-threaded heightfield generation
  • Free-slip particle-based hydraulic erosion
  • Programmable static/runtime-compiled pipeline
  • Biome generation
  • Multi-biome heightfield generation with smooth transition
  • Rule-based biome-dependent texture splatting with smooth transition
  • Adaptive distance-based texture scaling
  • River and lake generation

Procedural volumetric infinite terrain

  • Come up with a nice plan for this challenging topic

Procedural geometry generation

  • Volumetric cloud
  • Procedural object placement
  • Procedural animated grassland generation
  • Procedural tree generation
  • Procedural rock generation

Real-time photorealistic rendering

  • Procedural sky rendering
    • Atmospheric scattering
    • Aerial perspective
    • Seasonal effect
    • Starfield
    • Aurora
  • Deferred shading
  • Post-processing
    • Filmic tone mapping
    • Gamma correction
    • Auto-exposure
  • Shadow mapping
    • Simple shadow mapping for spotlight
    • Cubemap shadow mapping for point light
    • Cascaded shadow mapping for directional light
  • Ambient occlusion
    • Screen-space ambient occlusion
    • Horizon-based ambient occlusion
  • Anti-aliasing
    • Multi-sample anti-aliasing
    • Fast-approximate anti-aliasing
    • Morphological anti-aliasing
    • Temporal anti-aliasing
  • Multiple lights
    • Ambient light
    • Directional light
    • Point light
    • Spotlight
  • Water rendering
    • Procedural water wave animation
    • Screen-space reflection
    • Screen-space refraction
    • Fresnel effect
    • Caustics
    • Underwater crepuscular rays
  • Procedural weather effect

Real-time rasterisation-ray tracing hybrid rendering

  • Reflection
  • Refraction
  • Shadow
  • Ambient occlusion
  • Global illumination
  • Caustics

Optimisation technique

  • Reversed depth buffer
  • Frustum culling
  • Variable rate shading
  • Mesh shading
  • Deferred clustered lighting
  • Sparse virtual texture

🧱 Middleware

Main engine:

Demo program:

Test program:

🏗️ Project Structure

🗂️ Directory structure

  • SuperDemo+
  • SuperTerrain+
    • SuperAlgorithm+
      • Device
      • Host
    • SuperRealism+
    • SuperTerrain+
  • SuperTest+

🎯 Build targets

  • GLAD: Pre-compilation of glad.c for source and GL-context sharing among build targets.
  • SuperTerrain+: Main procedural terrain generation engine.
    • SuperAlgorithm+: A library of useful algorithms for terrain generation.
      • SuperAlgorithm+Host: Algorithms that are best suited for CPU execution.
      • SuperAlgorithm+Device: Algorithms that can be benefited from mass parallel computing using GPU.
    • SuperRealism+: A rendering engine for photorealistic rendering, with some handy GL functions and object wrappers.
  • SuperDemo+: An application which demonstrates the usage of the main engine.
  • SuperTest+: Unit test program.

☑️ Compile-time configurations

Option Note Default
STP_CUDA_RUNTIME_LIBRARY Set the global nvcc compiler flag -cudart= to the value set Shared
STP_BUILD_DEMO Enable SuperDemo+ program build ON
STP_DEVELOPMENT_BUILD Enable development mode OFF
STP_DEVELOPMENT_BUILD::STP_CUDA_VERBOSE_PTX Append to the global nvcc compiler flag with --ptxas-options=-v ON::ON
STP_DEVELOPMENT_BUILD::STP_BUILD_TEST Enable SuperTest+ program build ON::ON
STP_DEVELOPMENT_BUILD::STP_ENABLE_WARNING Enable all compiler warnings ON::ON

Note that :: denotes a CMake dependent option. Pattern A::B default to valueA::valueB means option B is depended on option A, and B is exposed in CMake cache set to valueB by default if and only if A is set to valueA; otherwise B is hidden from the user and set to NOT valueB.

📑 Getting Started

🖥️ Prerequisites

Hardware requirement

  • CPU

Intel CPU Requirement AMD CPU Requirement

  • GPU

SuperTerrain+ is currently exclusive to Nvidia GPUs. Ray tracing is powered by Nvidia OptiX; unlike DXR or VKR, it does not require a RTX board to run, but we still recommend using such graphics card for the best performance.

Legacy Ray Tracing
Nvidia GPU Requirement Legacy Nvidia GPU Requirement Ray Tracing
  • OS

The project is mainly developed with Visual Studio 2019 on Windows 10, and occasionally tested on some Linux systems with GCC. The codebase does not rely on any OS-specific API or feature, it should be portable if you are using other environment. Please note that I am not a Mac user and don't personally own a Mac device, hence the project is untested on MacOS.

OS Linux OS Windows

OpenGL extension requirement

This is usually not a problem if your GPU meets the minimum system requirement and have a relatively recent driver installed. If you are unsure, we recommend checking with OpenGL Extensions Viewer or online extension database.

The following extensions are not required but will be made used by the engine automatically whenever applicable.

⚙️ Build Instruction

External Dependency

To reduce the size of repository and keep everything clean, all external materials are not included in the commit.

To simplify the setup process for the first-time build, the following resources are managed automatically by CMake and no additional setup is required. All the rest of the aforementioned dependencies are required to be installed on your computer.

  • Assets such as texture
  • stb_image.h
  • Generated GLAD

CMake will download the required files, from either GitHub Releases in this repository, or the respective repository of 3rd-party library, to a directory STPResourceCache located at the root of your binary directory. The build system will not re-download them if they already exist. The build system will automatically update these files whenever a newer version is available. Otherwise, if your older version fails to compile or run, simply deleting the respective directory within STPResourceCache can purge the cache and will force a re-download next time the program is built.

Build

SuperTerrain+ uses CMake to build and it behaves similarly to most CMake projects. You may skip these basic instructions if you are familiar to CMake and instead focusing on setting up dependencies and CMake options.

# use shallow clone to speed up if you only wish to run the demo
# for development purposes please do a blob-less clone by replacing `--depth 1` with `--filter=blob:none`
# avoid full clone due to large assets in the commit history
git clone -b master --depth 1 https://github.com/stephen-hqxu/superterrainplus.git

cd ./superterrainplus

mkdir build
cd ./build

cmake ../

SuperTerrain+ build script automatically searches for dependencies; in case of any error, please make sure you have all third-party libraries installed on your computer. You may want configure CMakeCache.txt before moving on to the next step to build the application.

REM Windows; you can either compile via Visual Studio GUI from the generated VS solution,
REM or alternatively the command line like this
cmake --build ./ --config Release --target ALL_BUILD

Or:

# Unix
make all

Compilation of the engine may take up to 5 minutes. You may obtain the following executables:

  • SuperDemo+ if demo build is enabled
  • SuperTest+ if test build is enabled

📚 Credits

This section contains source code and libraries that are not dependencies of this project but they are where ideas and inspirations are taken from. I will try my best to give attributions and copyright notices for all publications used; in case something is missing, please open an issue.

For redistributed / adapted / derived open source projects, see 3rd-Party directory to find their licenses. For academic style BibTex references, check out the Report directory. Unless otherwise specified by licenses listed in 3rd-Party directory, all works presented in this repository are distributed under the license as stated in LICENSE file.

Utility

Terrain generation

Geometry generation

Photorealistic rendering

Shadow

Night rendering

HDR

Assets