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
Use the makefile to compile the program.
make all
Erosion System:
- gcc
- glm
Renderer:
- TinyEngine (and sub dependencies)
./hydrology [SEED]
If no seed is specified, it will take a random one.
- 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
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.
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.
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 for this program exist:
https://github.com/pawel-mazurkiewicz/SimpleHydrologyWindows
https://github.com/Roipo/SimpleHydrology
MIT License.
See my website for a more detailed copyright notice.