mln-rs-engine 0.0.22

Part of mln-rs, a MapLibre map renderer written in Rust. Depend on mln-rs instead.
Documentation
//! The blocks of the sky, the atmosphere and the layer composite.

use mln_gfx::shaders::block::uniform_block;

uniform_block! {
    /// The sky properties uniform block. The colors are premultiplied
    /// r, g, b, a floats.
    pub struct SkyPropsUBO {
        pub sky_color: [f32; 4],
        pub horizon_color: [f32; 4],
        pub horizon: [f32; 2],
        pub horizon_normal: [f32; 2],
        pub viewport_size: [f32; 2],
        pub sky_horizon_blend: f32,
        /// How far the view has turned to the globe: 0 draws the flat
        /// horizon, 1 the globe's.
        pub sky_blend: f32,
        /// From clip space to unit-sphere space around the camera, whose
        /// points are the directions of the view's rays.
        pub inv_view_projection: [f32; 4 * 4],
        /// The planet's center from the camera, in its radii.
        pub globe_center: [f32; 4],
        /// The logical pixels that a radian takes at the center of the view.
        pub pixels_per_radian: f32,
        pub pixel_ratio: f32,
        /// The `atmosphere-blend` that shows, which the sky fades out under.
        pub atmosphere_blend: f32,
        pub pad0: f32,
    }
}

uniform_block! {
    /// The atmosphere properties uniform block.
    pub struct AtmospherePropsUBO {
        pub inv_view_projection: [f32; 4 * 4],
        pub camera_position: [f32; 4],
        /// The fourth component stores the evaluated atmosphere blend.
        pub sun_position: [f32; 4],
    }
}

uniform_block! {
    /// The layer composite shader's uniform block: the opacity the
    /// layer's texture is composited with, and the blend the shader computes
    /// against the backdrop texture.
    pub struct LayerCompositeUBO {
        pub opacity: f32,
        /// One of the `LayerCompositeBlendMode` values.
        pub blend: i32,
        pub pad2: f32,
        pub pad3: f32,
    }
}

/// How the layer composite shader blends the texture with the backdrop.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[repr(i32)]
pub enum LayerCompositeBlendMode {
    /// The texture is drawn as it is, for the pipeline's blend to composite.
    None = 0,
    // The shader composites the texture over the backdrop with these blend modes
    // of the W3C compositing spec, which no blend function expresses.
    Multiply = 1,
    Overlay = 2,
    Color = 3,
    Luminosity = 4,
    HardLight = 5,
    Difference = 6,
    Exclusion = 7,
    Darken = 8,
    Lighten = 9,
    SoftLight = 10,
    ColorDodge = 11,
    ColorBurn = 12,
    Hue = 13,
    Saturation = 14,
}