weigert/SimpleHydrology

Procedural Hydrology / River / Lake Simulation

C++

751

103 commits

updated Mar 20, 2023

See the code

README

SimpleHydrology

C++ implementation of a particle based procedural hydrology system for terrain generation. This extends simple particle based hydraulic erosion to capture streams and pools.

Rendered using my homebrew TinyEngine.

Link to a blog post about this

Banner Image

Compiling

Use the makefile to compile the program.

make all

Dependencies

Erosion System:
- gcc
- glm

Renderer:
- TinyEngine (and sub dependencies)

Usage

./hydrology [SEED]

If no seed is specified, it will take a random one.

Controls

- Zoom and Rotate Camera: Scroll
- Arrow Keys: Move Camera Position
- WASD / C / V: Move Camera Anchor
- Toggle Pause: P (WARNING: PAUSED BY DEFAULT!!)
- Toggle Map View: M
- Toggle Hydrology Map View: ESC

Screenshots

Example Output 1

Example Output 2

Example Output 3

Example Output 4

Example Output 5

Reading

The main file is just to wrap the OpenGL code for drawing. At the very bottom, you can see the main game loop that calls the erosion and vegetation growth functions.

The part of the code described in the blog article is contained in the file water.h. Read this to find the implementation of the procedural hydrology.

The trees are implemented in vegetation.h.

All of the code is wrapped with the world class in world.h. The bottom of this file contains a bunch of stuff relevant for rendering, but not the erosion system.

The rest is shaders and rendering stuff.

Update October 2021

The rendering system has been updated to use vertex pooling to remove all remeshing cost.

Improvements have also been made to the flooding algorithm to increase the search plane at fixed, deterministic increments by iteratively looking for the lowest point on the boundary. Additionally, the region can be grown by only tracking the boundary.

For a next iteration on this system, see SoilMachine.

Update January 2023

The flooding system has been removed for now, because of buggyness and slowness. A better system has been proposed here.

Momentum and discharge maps are now explicit and interact physically with the water particles, giving river meandering behavior.

Parameters have been properly separated out.

Libnoise dependency has been removed.

Windows Ports

Windows ports for this program exist:

https://github.com/pawel-mazurkiewicz/SimpleHydrologyWindows

https://github.com/Roipo/SimpleHydrology

License

MIT License.

See my website for a more detailed copyright notice.

erosion
erosion-process
hydrology
hydrology-simulation
procedural
procedural-generation
procedural-terrain
terrain
terrain-generation
terrain-rendering

weigert/SimpleHydrology

Procedural Hydrology / River / Lake Simulation

C++

751

103 commits

updated Mar 20, 2023

See the code

README

SimpleHydrology

C++ implementation of a particle based procedural hydrology system for terrain generation. This extends simple particle based hydraulic erosion to capture streams and pools.

Rendered using my homebrew TinyEngine.

Link to a blog post about this

Banner Image

Compiling

Use the makefile to compile the program.

make all

Dependencies

Erosion System:
- gcc
- glm

Renderer:
- TinyEngine (and sub dependencies)

Usage

./hydrology [SEED]

If no seed is specified, it will take a random one.

Controls

- Zoom and Rotate Camera: Scroll
- Arrow Keys: Move Camera Position
- WASD / C / V: Move Camera Anchor
- Toggle Pause: P (WARNING: PAUSED BY DEFAULT!!)
- Toggle Map View: M
- Toggle Hydrology Map View: ESC

Screenshots

Example Output 1

Example Output 2

Example Output 3

Example Output 4

Example Output 5

Reading

The main file is just to wrap the OpenGL code for drawing. At the very bottom, you can see the main game loop that calls the erosion and vegetation growth functions.

The part of the code described in the blog article is contained in the file water.h. Read this to find the implementation of the procedural hydrology.

The trees are implemented in vegetation.h.

All of the code is wrapped with the world class in world.h. The bottom of this file contains a bunch of stuff relevant for rendering, but not the erosion system.

The rest is shaders and rendering stuff.

Update October 2021

The rendering system has been updated to use vertex pooling to remove all remeshing cost.

Improvements have also been made to the flooding algorithm to increase the search plane at fixed, deterministic increments by iteratively looking for the lowest point on the boundary. Additionally, the region can be grown by only tracking the boundary.

For a next iteration on this system, see SoilMachine.

Update January 2023

The flooding system has been removed for now, because of buggyness and slowness. A better system has been proposed here.

Momentum and discharge maps are now explicit and interact physically with the water particles, giving river meandering behavior.

Parameters have been properly separated out.

Libnoise dependency has been removed.

Windows Ports

Windows ports for this program exist:

https://github.com/pawel-mazurkiewicz/SimpleHydrologyWindows

https://github.com/Roipo/SimpleHydrology

License

MIT License.

See my website for a more detailed copyright notice.

erosion
erosion-process
hydrology
hydrology-simulation
procedural
procedural-generation
procedural-terrain
terrain
terrain-generation
terrain-rendering

Significant stargazers

CharlesCNorton

230 followers · starred Dec 2025

Martin Gerhardy

161 followers · starred Jun 2022

Robin Voetter

280 followers · starred Dec 2023

Nick Porcino

484 followers · starred Jan 2024