• Stars
    star
    430
  • Rank 101,083 (Top 2 %)
  • Language
    C#
  • License
    MIT License
  • Created over 7 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Terrain topology algorithms in Unity

Terrain-Topology-Algorithms

This project is collection of algorithms that can be used to describe the topology of a terrain. The result of these algorithms can then be used for rendering the terrain or as input to other algorithms.

The formulas were taken from a book called Digital Terrain Analysis for Soil Science.

Version 2 adds more curvature types, landform and residual types as well as a better way to visualize the maps using a color gradient and rescaling the wide dynamic range using a logarithmic scale.

The colorized maps can be displayed using a cool to warm or black to white gradient.

Normal map

The normal map is probably the most common algorithm used to describe the topology of a terrain because of its use in rendering. The normal's are a tangent space vector of the surface direction.

Its a good place to start as it requires calculating the first order derivatives of the terrains height map which are also used in many of other algorithms.

Normal Map

Slope map

The slope map describes the steepness of the terrain and is handy for texturing the terrain. Like the normal map this also requires the first order derivatives.

Slope Map

Aspect map

This is similar to the slope map but instead represents the horizontal gradient as opposed to the vertical gradient.

Aspect Map

Curvature map

The curvature map represents the convexity/concavity of the surface. The curvature is a little more complicated to calculate and requires the first and second order derivatives of the terrains height.

There are a lot of ways to measure the curvature. The most useful are vertical, horizontal, mean, gaussian, minimal or maximal curvature but I have provide a few others.

Since curvature uses the second derivatives it can have quite a large dynamic range and can be negative which makes visualizing the map a bit tricky.

Below is the horizontal, vertical, gaussian, minimal and maximal curvatures in that order.

Curvature Map

Curvature Map

Curvature Map

Curvature Map

Curvature Map

Landform map

The landform map combines some of the curvature values to try and classify the type of landform. For example if the landform is convex/concave or accumulative/dispersive.

The idea is the the shape of the landform determines how water flows over it which is a key indicator for soil type and depth.

Below is the shape index and accumulation landforms in that order.

Landform Map

Landform Map

Flow map

This one is a bit different as its a iterative algorithm and is therefore a bit slow. Its works by simulating the path a small amount of water flowing over the terrain will take. The magnitude of the waters velocity can then be used to create a flow map.

Its a good way to make rivers or erosion effects.

Flow Map

Residual map

The residual map takes the heights around a point in a given window and performs some sort of statistical analysis. For example the standard deviation represents the roughness of the terrain.

Options to calculate the mean, standard deviation, percentile and a few others are provided.

Below is the percentile map where the value represents the percentage of heights around a point that are lower.

Residual Map

More Repositories

1

Ceto

Ceto: Ocean system for Unity
C#
1,015
star
2

PBD-Fluid-in-Unity

A PBD fluid in unity running on the GPU
C#
724
star
3

Marching-Cubes

Marching cubes in Unity
C#
462
star
4

Hull-Delaunay-Voronoi

Hull, Delaunay and Voronoi algorithms in Unity
C#
411
star
5

Brunetons-Improved-Atmospheric-Scattering

A Unity port of Brunetons improved atmospheric scattering
HLSL
354
star
6

Position-Based-Dynamics

Position based dynamics in Unity
C#
299
star
7

Marching-Cubes-On-The-GPU

A implementation of the marching cubes algorithm on the GPU in Unity.
C#
291
star
8

GPU-GEMS-3D-Fluid-Simulation

3D fluid simulation on the in Unity
C#
278
star
9

Phillips-Ocean

A ocean using Phillips spectrum in Unity
C#
272
star
10

GPU-GEMS-2D-Fluid-Simulation

2D fluid simulation in Unity
C#
247
star
11

Mesh-Voxelization

Mesh voxelization in Unity
C#
231
star
12

CGALDotNet

C# wrapper for CGAL
C#
198
star
13

Interactive-Erosion

Interactive erosion in Unity
C#
170
star
14

2D-Deformable-body-in-Unity

A 2D Deformable body simulation in Unity using FEM
C#
142
star
15

Procedural-Noise

Simple examples of noise algorithms in Unity
C#
136
star
16

Brunetons-Ocean

Brunetons ocean in Unity
C#
127
star
17

Tiled-Directional-Flow

A shader to control the direction water flows based on a flow map in Unity.
ShaderLab
118
star
18

Proland-To-Unity

A port of Proland to Unity
C#
112
star
19

GPU-GEMS-Atmospheric-Scatter

Atmoshperic scatter in Unity
GLSL
73
star
20

AperiodicTexturing

A periodical texturing in Unity
C#
66
star
21

CGALDotNetUnity

CGALDotNet examples in Unity
C#
60
star
22

Brunetons-Atmospheric-Scatter

Brunetons procomputed atmospheric scatting in Unity
C#
55
star
23

GPU-Voronoi-Noise

GPU Voronoi noise in Unity
HLSL
48
star
24

CyclonePhysicsEngine

C# port of the Cylcone physics engine
C#
47
star
25

Wireframe-Shader

A wireframe material in Unity using the geometry shader.
ShaderLab
47
star
26

Simple-Procedural-Terrain

A simple example of how to create a Unity terrain from code using procedural noise.
C#
45
star
27

GPU-GEMS-NBody-Simulation

A NBody simulation in Unity
C#
43
star
28

GPU-GEMS-Improved-Perlin-Noise

Perlin noise on the GPU in Unity
GLSL
42
star
29

CGALDotNetGeometry

Geometry objects under MIT licence for CGALDotNet project
C#
28
star
30

ImageProcessing

A collection of code for processing images
C#
22
star
31

XAtlasDotNet

A c# wrapper around xatlas used to unwrap mesh uv’s.
C++
14
star
32

Common

Common code library
C#
9
star
33

OpenCLDotNet

A C# wrapper around OpenCL
C#
2
star