Terrain Erosion Demo
A little tech demo by @DetectiveLosos.
Demo workflow overview:
- Create some 512x512 rendertextures (two of some textures are needed to switch between them and process data from one to another):
- Two for terrain (R - terrain height, G - soil height, B - suspended soil, A - grass cover).
- One for terrain normals (RGB - terrain normal).
- One for terrain ambient occlusion (R - terrain occlusion, and it's actually 256x256).
- One for terrain flow (RGBA - flow left, right, up, down).
- Two for water (R - water height, GB - water velocity, A - clouds).
- Two for water flow(RGBA - flow left, right, up, down).
- Generate terrain height values with couple octaves of Simplex noise and couple octaves of Voronoi noise. Here is a very useful page about noises in general. And here is a page about voronoi noise.
- Add water, evaporate water: Water height is growing under the clouds (wich are invisible in this demo). Still water with lower values of velocity (in the middle of lakes) evaporates.
- Calculate water flow: Water flow is amout of water needed to be transported from current cell to it's neighbors. Water flow is calculated based on the previous value + (terrain height + water height difference between current cell and left, right, top, bottom neighbor).
- Apply water flow: Change water height based on the previously calculated water flow values.
- Calculate terrain flow: Terrain flow is a terrain smothing but only in the cell with some eroded soil in them. Terrain flow is calculated based on a terrain height difference between current cell and it's left, right, top, bottom neighbor. It only occures if there is water in the current cell.
- Apply terrain flow: Change terrain height and soil amount based on the previously calculated water flow values.
- Calculate and apply terrain erosion: If there is water above the current cell, then based on it's velocity and amount turn some of the rock to soil.
- Calculate and apply soil pickup, transport and drop: Calculate water carry capacity based on water velocity, water amount and terrain normal in relation to the flow direction. If water carry capacity is higher then suspended soil amount in the current cell, then turn some soil into suspended soil, else turn some suspended soil into regular soil. Change terrain height accordingly.
- Recalculate terrain normals and ambient occlusion.
- Render terrain and water.
- Go to step 3.
The technique used in general is similar to the one described here, but there is quite a difference regarding an approach to erosion, water flow and terrain processing, wich are based on this paper instead. In my opinion that web demo produces far better results than the one I came up with, but oh well, what are you gonna do.
Alongside dynamic water and terrain erosion systems this demo features custom adaptive LOD system for terrain and water rendering.
Leave a comment
Log in with itch.io to leave a comment.