Skip to content
/ Rainfall Public

Simulation of hydraulic erosion across a heightfield

License

Notifications You must be signed in to change notification settings

Vehxx/Rainfall

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rainfall

Overview

Java implementation of a particle-based hydraulic erosion simulation algorithm. The program accepts a heightmap in the form of a 2D array of floats and returns a 2D array of floats.

Below is a render of a 512x512 grid of fractal noise which was run through the program with the default parameters. This simulation was allowed to run for 2 million iterations.

erosion_render_0 3f_big

Because flow of the simulated raindrops across the terrain emulates real-life physics, geographical features which are present in real terrain manifest in the simulation as well. Features such as gullies on the sides of mountains, sediment-filled valleys, and alluvial fans - where water drains from a narrow passage into a wider area - all appear.

Here is a 'timelapse' of the heightmap which was passed through the program and used to create the above render. One picture was saved after every 10,000 raindrops were simulated, for a total of 200 frames.

timelapse

Dependencies

The only dependency this project has is JOML - the Java OpenGL Math Library. This is used to quickly perform vector math in order to simulate the raindrop physics. In the driver code, I am using FastNoiseLite to generate the fractal noise which is passed into the algorithm.

Rainfall:
- Java OpenGL Math Library

Driver:
- FastNoiseLite

Settings

Rainfall makes use of 5 basic variables which can be changed to achieve different results.

Scale

Scale is used as a multiplier for determining the surface normal at any given point. Increasing this value would cause a raindrop to move a farther distance, whereas decreasing it would cause it to move a shorter distance. This is because the scale directly affects the speed of the raindrop. Acceleration = force / mass, and this variable determines the force in that equation.

Density

Density is used to calculate the acceleration of the raindrop as it flows across the heightmap. Acceleration = force / mass, and mass is calculated by volume * density. Therefore, increasing the density causes the raindrop to accelerate more slowly.

Friction

Friction is a multiplier which effects the speed of the raindrop after it moves across a surface. Higher friction means lower speeds.

Evaporation Rate

Evaporation rate is how many times the raindrop can move to a new position before it is terminated. By default, this number is set to the 1 / the length of the X axis.

Deposition Rate

Deposition rate is a multiplier which controls how much sediment is deposited to the terrain.

Here is an example of the difference between an output with this value set to 0.3f (default), vs 0.1f, with no other changes.

dep_comparison

Screenshots

Here's a before and after shot of a render of the unprocessed fractal noise vs the same noise which was run through Rainfall:

erosion_comparison

About

Simulation of hydraulic erosion across a heightfield

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages