Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/quentinwach/terra
The tiny terrain generator ⛰.
https://github.com/quentinwach/terra
3d-graphics erosion erosion-simulation geography geometry graphics landscape procedural procedural-generation procedural-terrain procedural-textures programmatic simulation tectonic terraform terrain terrain-generation weather
Last synced: about 1 month ago
JSON representation
The tiny terrain generator ⛰.
- Host: GitHub
- URL: https://github.com/quentinwach/terra
- Owner: QuentinWach
- License: other
- Created: 2024-08-14T15:33:02.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-09-02T19:06:13.000Z (2 months ago)
- Last Synced: 2024-10-11T04:40:20.309Z (about 1 month ago)
- Topics: 3d-graphics, erosion, erosion-simulation, geography, geometry, graphics, landscape, procedural, procedural-generation, procedural-terrain, procedural-textures, programmatic, simulation, tectonic, terraform, terrain, terrain-generation, weather
- Language: Python
- Homepage:
- Size: 15.8 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
**The tiny terrain generator.**
Maintained by [Quentin Wach](https://www.x.com/QuentinWach).
[Examples](#examples) ▪ [Features](#features)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![GitHub Repo stars](https://img.shields.io/github/stars/QuentinWach/terra)](https://github.com/QuentinWach/terra/stargazers)
[![GitHub latest commit](https://badgen.net/github/last-commit/QuentinWach/terra)](https://github.com/QuentinWach/terra/commits/main)**_Terra_ provides various physics simulations, geological primitives, tesselations, filters, and more to generate realistic terrains.** (It's pretty bad right now but getting better!)
## Examples
![](docs/render_4.png)
**Example 1. Eroded Mountains.** The heightmap and colormap were generated with _Terra_ using the code below then exported and rendered in Blender. Fractal Perlin noise is used to generate the terrain. In order to make the terrain more mountain-like, a custom pointify filter is applied on every level of the Perlin noise. Lastly, we simulate 20,000 particles for hydraulic erosion.
```python
heightmap = pointy_perlin(X=600, Y=600, scale=100)
eroded_heightmap, path_map = erode(heightmap, num_iterations=20000)
export(heightmap, 'terrain.png', cmap='Greys_r')
export(eroded_heightmap, 'erosion.png', cmap='Greys_r')
export(eroded_heightmap, "erosion_color.png", cmap=terrain_cmap())
export(np.log1p(path_map), 'path_map.png', cmap='Blues')
```
As you can see, it only takes two lines to create the terrain! Everything else is just exporting the various maps that are generated. Below is a more simpler example showing some of the maps:![](docs/height_colour_normal_example.png)
**Example 2. A Tiny Island.** Using fractal Perlin noise with the pointify effect at every level, a simple island can be generated effortlessly. The image here shows the heightmap, the colourmap, and normal map generated with _Terra_.
```python
island = hill(500, 500)
export(island, "hill.png", cmap="Greys_r")
export(island, "hill_coloured.png", cmap=terrain_cmap())
export(normal_map(island), "hill_normal.png", cmap="viridis")
```---
## Features
The [example shown above](#example) involved various steps. With very few functions, _Terra_ still offers a lot of flexibility in creating terrains.### Randomness `random`
+ [X] Normal Distribution
+ [X] Perlin Noise
+ [X] Billow Noise
+ [X] Fractal Perlin Noise
+ [X] Warping
+ [X] [Pointify](https://www.youtube.com/watch?v=gsJHzBTPG0Y)
+ [X] Pointy Perlin### Tesselation `tess`
+ [X] Voronoi Tesselation
+ [X] Tesselation Relaxation with Fortune's Algorithm
+ [X] Tesselated Height Map with Constant Elevation per Cell
### Rendering `render`
+ [X] Linear Gradient
+ [X] Whittaker Biome Classification and Color Map
+ [X] 2D Map Export (i.e. to generate a 3D file and render it in Blender)
+ [X] Radial Gradient / Mask
+ [X] Standard Terrain Height Map
+ [X] Normal Map Calculation
+ [X] Gradient of Map
+ [X] Divergence of Map
+ [X] Import (i.e. to import images to be used as height maps, filters, assets etc.)
+ [X] Gras Shader: Grow Gras Only on Flat, Low Areas
+ [X] Snow Deposition
+ [ ] High-Res Exports for maps for better rendering and re-use### Simulation `sim`
+ [X] [Hydraulic Single-Particle Terrain Erosion](https://www.youtube.com/watch?v=eaXk97ujbPQ)
+ [ ] Optimized Erosion Rain Pattern: Rain Only Over Mountain Peaks to Speed Up the Erosion Effect
+ [ ] 🔨 _NEXT:_ [Fast Physically-Based Analytical Erosion](https://www.youtube.com/watch?v=zKnluMlRZNg)
+ [X] First version
+ [ ] Improve the rain pattern
+ [ ] Improve the flux/motion of the water
+ [ ] Improve evaporation
+ [ ] Fix the common hole-digging error with an add. heuristic
+ [ ] 🔨 _NEXT:_ [Fractal Pixel Mountain Generation](https://www.youtube.com/watch?v=gsJHzBTPG0Y)### Geo Primitives
+ [X] Hill
+ [ ] 🔨 _NEXT:_ Mountains
+ [ ] 🔨 _NEXT:_ Dunes### Manual Edit
+ [ ] Add and subtract by drawing on any map---
## Other Links
+ [World Building Pasta](https://worldbuildingpasta.blogspot.com/). A phenomenal and in-depth blog about everything that shapes planets, their terrain, and how to create new worlds yourself.---
## Get Started
Clone the repository or download it as a zip. Create or open a local Python environment (I recommend Anaconda) and install the dependencies `dependencies.txt`.---
## 🤝🏻 Contribute
**There is much to do.** The plan:
1. Implement various terrain generation algorithms and tools quickly in Python.
2. Optimize the performance for real-time and large scales by improving the algorithms, using C, and the GPU.
3. Create a GUI interface.At this point, Terra is pretty much just educational. But it doesn't have to be. Leave your mark and add to this Python library. You know how it goes. You found a bug? Add an issue. Any ideas for improvement or feeling the need to add more features? Clone the repository, make the changes, and submit a pull request, or...
> **Leave a ⭐ to show your support!**
[_MIT License_](LICENSE.txt)