use mln_gfx::shaders::block::uniform_block;
uniform_block! {
pub struct TerrainDrawableUBO {
pub dem_coords: [f32; 4],
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct TerrainProps {
pub unpack: [f32; 4],
pub unpack_scale: f32,
pub exaggeration: f32,
pub skirt_length: f32,
}
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct TerrainFog {
pub fog_color: [f32; 4],
pub horizon_color: [f32; 4],
pub depth_range: [f32; 2],
pub ground_blend: f32,
pub horizon_blend: f32,
}
impl TerrainFog {
pub const NONE: TerrainFog = TerrainFog {
fog_color: [0.0; 4],
horizon_color: [0.0; 4],
depth_range: [0.0; 2],
ground_blend: 1.0,
horizon_blend: 1.0,
};
}
uniform_block! {
pub struct TerrainSurfaceUBO {
pub unpack: [f32; 4],
pub unpack_scale: f32,
pub exaggeration: f32,
pub skirt_length: f32,
pub pad0: f32,
pub fog_color: [f32; 4],
pub horizon_color: [f32; 4],
pub depth_range: [f32; 2],
pub ground_blend: f32,
pub horizon_blend: f32,
}
}
impl TerrainSurfaceUBO {
#[must_use]
pub const fn new(props: &TerrainProps, fog: &TerrainFog) -> TerrainSurfaceUBO {
TerrainSurfaceUBO {
unpack: props.unpack,
unpack_scale: props.unpack_scale,
exaggeration: props.exaggeration,
skirt_length: props.skirt_length,
pad0: 0.0,
fog_color: fog.fog_color,
horizon_color: fog.horizon_color,
depth_range: fog.depth_range,
ground_blend: fog.ground_blend,
horizon_blend: fog.horizon_blend,
}
}
}
pub const MAX_ILLUMINATION_SOURCES: usize = 4;
uniform_block! {
pub struct HillshadeTilePropsUBO {
pub latrange: [f32; 2],
pub exaggeration: f32,
pub method: i32,
pub num_lights: i32,
pub pad0: f32,
pub pad1: f32,
pub pad2: f32,
}
}
uniform_block! {
pub struct HillshadeEvaluatedPropsUBO {
pub accent: [f32; 4],
pub altitudes: [f32; 4],
pub azimuths: [f32; 4],
pub shadows: [[f32; 4]; MAX_ILLUMINATION_SOURCES],
pub highlights: [[f32; 4]; MAX_ILLUMINATION_SOURCES],
}
}