Skip to main content

euv_core/game/engine3d/modeling/terrain/
struct.rs

1use super::*;
2
3/// Parametric configuration controlling multi-noise synthesis, terracing, and erosion of a `HeightfieldTerrain`.
4#[derive(Clone, Copy, Data, Debug, PartialEq)]
5pub struct TerrainConfig {
6    /// Grid resolution along the X axis (`2..=512`).
7    #[get(type(copy))]
8    pub(crate) grid_x: u32,
9    /// Grid resolution along the Z axis (`2..=512`).
10    #[get(type(copy))]
11    pub(crate) grid_z: u32,
12    /// Total world-space width along the X axis.
13    #[get(type(copy))]
14    pub(crate) world_size_x: f32,
15    /// Total world-space depth along the Z axis.
16    #[get(type(copy))]
17    pub(crate) world_size_z: f32,
18    /// Vertical elevation amplitude multiplier.
19    #[get(type(copy))]
20    pub(crate) height_scale: f32,
21    /// Deterministic 64-bit random seed for noise and droplet erosion.
22    #[get(type(copy))]
23    pub(crate) seed: u64,
24    /// Number of fractal Brownian motion noise octaves (`1..=8`).
25    #[get(type(copy))]
26    pub(crate) fbm_octaves: u32,
27    /// Base spatial frequency for multi-octave terrain noise.
28    #[get(type(copy))]
29    pub(crate) fbm_frequency: f32,
30    /// Frequency multiplier per octave.
31    #[get(type(copy))]
32    pub(crate) fbm_lacunarity: f32,
33    /// Amplitude decay multiplier per octave.
34    #[get(type(copy))]
35    pub(crate) fbm_persistence: f32,
36    /// Blend weight for sharp ridged multifractal mountain crests (`0.0..=1.0`).
37    #[get(type(copy))]
38    pub(crate) ridged_weight: f32,
39    /// Blend weight for Worley cellular canyon carving (`0.0..=1.0`).
40    #[get(type(copy))]
41    pub(crate) canyon_weight: f32,
42    /// Number of vertical plateau terrace steps (`0` disables terracing).
43    #[get(type(copy))]
44    pub(crate) terrace_steps: u32,
45    /// Blending strength of terracing plateaus (`0.0..=1.0`).
46    #[get(type(copy))]
47    pub(crate) terrace_strength: f32,
48    /// Number of simulated hydraulic rain droplets (`0` skips hydraulic erosion).
49    #[get(type(copy))]
50    pub(crate) hydraulic_droplets: u32,
51    /// Number of thermal talus slippage iterations (`0` skips thermal erosion).
52    #[get(type(copy))]
53    pub(crate) thermal_iterations: u32,
54    /// Maximum stable talus slope angle in radians for thermal erosion.
55    #[get(type(copy))]
56    pub(crate) talus_angle: f32,
57    /// Biome mask and vertex coloring preset.
58    #[get(type(copy))]
59    pub(crate) biome: TerrainBiome,
60}
61
62/// Generated heightfield terrain storing elevations, splat weights, vertex colors, and normal map bytes.
63#[derive(Clone, Data, Debug, PartialEq)]
64pub struct HeightfieldTerrain {
65    /// Grid resolution along X.
66    #[get(type(copy))]
67    pub(crate) grid_x: u32,
68    /// Grid resolution along Z.
69    #[get(type(copy))]
70    pub(crate) grid_z: u32,
71    /// Total world-space width along X.
72    #[get(type(copy))]
73    pub(crate) world_size_x: f32,
74    /// Total world-space depth along Z.
75    #[get(type(copy))]
76    pub(crate) world_size_z: f32,
77    /// Row-major height samples (`len == grid_x * grid_z`).
78    pub(crate) heights: Vec<f32>,
79    /// Per-vertex normalized splat weights `[grass, rock, snow, sand]`.
80    pub(crate) splat_weights: Vec<[f32; 4]>,
81    /// Per-vertex RGBA8 slope/altitude biome colors.
82    pub(crate) vertex_colors: Vec<[u8; 4]>,
83    /// Row-major RGBA8 normal map texture matching `(grid_x, grid_z)`.
84    pub(crate) normal_map: Vec<[u8; 4]>,
85    /// Minimum finite elevation present in `heights`.
86    #[get(type(copy))]
87    pub(crate) min_height: f32,
88    /// Maximum finite elevation present in `heights`.
89    #[get(type(copy))]
90    pub(crate) max_height: f32,
91}