9#include "resource/resource.h"
10#include "resource/resource_handle.h"
12#include "resource/asset/material_asset.h"
13#include "resource/asset/mesh_asset.h"
15namespace Vkm::Engine {
25 MaterialHandle material;
36 std::vector<TerrainPlantPart>
parts;
71 std::array<MaterialHandle, MaterialAsset::MAX_LAYERS>
layers{};
74 std::array<float, MaterialAsset::MAX_LAYERS>
layerTiling{4.0f, 4.0f, 4.0f, 4.0f};
Opaque, type-safe handle for resources, distinguished by ResourceType.
Definition resource_handle.h:16
A terrain: a square grid of heights, the share of each of four materials painted at each grid vertex,...
Definition terrain_asset.h:54
static bool validResolution(uint32_t resolution)
Whether resolution is one a terrain may have.
float heightAt(float x, float z) const
The height at local x, z, the surface its triangles draw there.
static constexpr uint32_t MAX_PLANT_PARTS
The most parts a plant has.
Definition terrain_asset.h:62
static constexpr uint32_t MIN_RESOLUTION
The fewest grid vertices a side: one chunk's.
Definition terrain_asset.h:56
glm::vec3 normalAt(int i, int j) const
The surface's normal at grid vertex i, j, from its neighbours' heights.
float spacing() const
Metres between neighbouring grid vertices.
Definition terrain_asset.h:79
float size
Metres a side.
Definition terrain_asset.h:65
std::vector< TerrainFoliage > foliage
Up to MAX_FOLIAGE.
Definition terrain_asset.h:76
std::array< float, MaterialAsset::MAX_LAYERS > layerTiling
Definition terrain_asset.h:74
uint32_t resolution
Grid vertices a side, 2^n + 1 from MIN_ to MAX_RESOLUTION.
Definition terrain_asset.h:64
std::vector< float > heights
resolution^2, row by row along X: metres up from the entity.
Definition terrain_asset.h:67
std::vector< uint8_t > weights
resolution^2 * 4: each vertex's share of the four layers, R to A.
Definition terrain_asset.h:68
std::array< MaterialHandle, MaterialAsset::MAX_LAYERS > layers
What each share is drawn with; an empty layer draws black where it is painted.
Definition terrain_asset.h:71
static constexpr uint32_t MAX_RESOLUTION
The most: what a terrain's meshes, collider and maps are sized for.
Definition terrain_asset.h:58
static constexpr uint32_t MAX_FOLIAGE
The most foliage layers.
Definition terrain_asset.h:60
bool resample(uint32_t to)
Regrid to to vertices a side over the same size, keeping the shape, the paint and the plants.
Plants a terrain scatters where their density is painted: grass, flowers, shrubs.
Definition terrain_asset.h:35
uint32_t seed
Picks where each plant stands and how it turns.
Definition terrain_asset.h:42
float perSquareMetre
Plants a square metre where the density is full.
Definition terrain_asset.h:38
std::vector< uint8_t > density
A grid vertex each: 255 is perSquareMetre, 0 none.
Definition terrain_asset.h:37
bool castShadows
Grass need not; a shrub looks afloat without.
Definition terrain_asset.h:43
float maxDistance
Metres from the eye past which none is drawn.
Definition terrain_asset.h:41
float maxScale
The largest.
Definition terrain_asset.h:40
float minScale
The smallest a plant is drawn, a share of its size.
Definition terrain_asset.h:39
std::vector< TerrainPlantPart > parts
One plant.
Definition terrain_asset.h:36
One part of a plant a terrain scatters: a mesh drawn with a material, placed in the plant.
Definition terrain_asset.h:23
glm::mat4 local
Where the part lies in the plant.
Definition terrain_asset.h:26