Generate a terrain with Perlin noise and erosion. Represent the terrain, regrouping elevation and shadow data and the underlying GPU representation to render it.
More...
#include <Terrain.hpp>
|
|
PerlinNoise | _perlin |
| | Perlin noise generator.
|
| |
|
std::vector< Cell > | _cells |
| | Grid mesh cells.
|
| |
|
Texture | _map = Texture("Terrain") |
| | Terrain map, height in R channel, normals in GBA channels.
|
| |
|
Texture | _mapLowRes = Texture("Terrain low-res") |
| | Low resolution min-height terrain map.
|
| |
|
Texture | _shadowMap |
| | Shadow map generation texture.
|
| |
|
GaussianBlur | _gaussBlur |
| | Gaussian blur.
|
| |
|
GenerationSettings | _genOpts |
| | Terrain generations settings.
|
| |
|
MeshSettings | _mshOpts |
| | Grid mesh options.
|
| |
|
ErosionSettings | _erOpts |
| | Erosion options.
|
| |
|
int | _resolution |
| | Height map resolution.
|
| |
|
uint | _seed |
| | Current generation seed.
|
| |
|
float | _texelSize = 0.05f |
| | Size of a map texel in world space.
|
| |
|
float | _meshSize = 0.0f |
| | Size of the mesh.
|
| |
Generate a terrain with Perlin noise and erosion. Represent the terrain, regrouping elevation and shadow data and the underlying GPU representation to render it.
◆ Terrain()
| Terrain::Terrain |
( |
uint |
resolution, |
|
|
uint |
seed |
|
) |
| |
Constructor
- Parameters
-
| resolution | the terrain map resolution |
| seed | the random seed for terrain generation |
◆ ~Terrain()
◆ cells()
| const std::vector< Cell > & Terrain::cells |
( |
| ) |
const |
|
inline |
- Returns
- the grid mesh cells.
◆ erode()
| void Terrain::erode |
( |
Image & |
img | ) |
|
|
private |
Apply erosion on a height map.
- Parameters
-
| img | the map to erode, in place |
◆ generateMap()
| void Terrain::generateMap |
( |
| ) |
|
Generate the terrain map for the current seed.
◆ generateMesh()
| void Terrain::generateMesh |
( |
| ) |
|
◆ generateShadowMap()
| void Terrain::generateShadowMap |
( |
const glm::vec3 & |
lightDir | ) |
|
Generate the shadow map for the current terrain and a sun direction.
- Parameters
-
| lightDir | the sun direction |
◆ gridSize()
| int Terrain::gridSize |
( |
| ) |
const |
|
inline |
- Returns
- the size of the grid.
◆ interface()
| bool Terrain::interface |
( |
| ) |
|
Display terrain options in GUI, in a currently opened window.
- Returns
- true if any option was modified
◆ map()
| const Texture & Terrain::map |
( |
| ) |
const |
|
inline |
- Returns
- the terrain height and normal map.
◆ meshSize()
| float Terrain::meshSize |
( |
| ) |
const |
|
inline |
- Returns
- the size of the grid in world space.
◆ shadowMap()
| const Texture & Terrain::shadowMap |
( |
| ) |
const |
|
inline |
- Returns
- the terrain shadow map, with self shadowing in the R channel and ocean plane shadowing in the G channel.
◆ texelSize()
| float Terrain::texelSize |
( |
| ) |
const |
|
inline |
- Returns
- the size of a terrain map pixel in world space.
◆ transferAndUpdateMap()
| void Terrain::transferAndUpdateMap |
( |
Image & |
heightMap | ) |
|
|
private |
Compute terrain normals from height and uplaod the result to the GPU, with custom mip-map and low-res version.
- Parameters
-
| heightMap | the map to update and upload |
The documentation for this class was generated from the following files:
- src/apps/island/Terrain.hpp
- src/apps/island/Terrain.cpp