mln-rs-engine 0.0.21

Part of mln-rs, a MapLibre map renderer written in Rust. Depend on mln-rs instead.
Documentation
//! The engine's programs.

use mln_gfx::shaders::program::{Program, ProgramBuffer, ProgramTexture, Projection, Stages};
use mln_gfx::shaders::source::Sources;

use super::ubo::{AtmospherePropsUBO, LayerCompositeUBO, SkyPropsUBO};
use super::{glsl, glsl_es, msl, wgsl};
use crate::draw::POS;

pub static CLIPPING_MASK: Program = Program {
    name: "ClippingMaskProgram",
    buffers: &[],
    paint_params: None,
    projection: Projection::Own,
    attributes: &[POS],
    instance_attributes: &[],
    textures: &[],
    properties: &[],
    sources: Sources::NONE
        .wgsl(&wgsl::CLIPPING_MASK)
        .msl(&msl::CLIPPING_MASK)
        .glsl(&glsl::CLIPPING_MASK)
        .glsl_es(&glsl_es::CLIPPING_MASK),
};

pub static GLOBE_DEPTH: Program = Program {
    name: "GlobeDepthShader",
    buffers: &[],
    paint_params: None,
    projection: Projection::PerDraw,
    attributes: &[POS],
    instance_attributes: &[],
    textures: &[],
    properties: &[],
    sources: Sources::NONE
        .wgsl(&wgsl::GLOBE_DEPTH)
        .msl(&msl::GLOBE_DEPTH)
        .glsl(&glsl::GLOBE_DEPTH)
        .glsl_es(&glsl_es::GLOBE_DEPTH),
};

pub static SKY: Program = Program {
    name: "SkyShader",
    buffers: &[ProgramBuffer::uniform::<SkyPropsUBO>("sky", 0, Stages::Both)],
    paint_params: None,
    projection: Projection::None,
    attributes: &[POS],
    instance_attributes: &[],
    textures: &[],
    properties: &[],
    sources: Sources::NONE.wgsl(&wgsl::SKY).msl(&msl::SKY).glsl(&glsl::SKY).glsl_es(&glsl_es::SKY),
};

pub static ATMOSPHERE: Program = Program {
    name: "AtmosphereShader",
    buffers: &[ProgramBuffer::uniform::<AtmospherePropsUBO>("atmosphere", 0, Stages::Both)],
    paint_params: None,
    projection: Projection::None,
    attributes: &[POS],
    instance_attributes: &[],
    textures: &[],
    properties: &[],
    sources: Sources::NONE
        .wgsl(&wgsl::ATMOSPHERE)
        .msl(&msl::ATMOSPHERE)
        .glsl(&glsl::ATMOSPHERE)
        .glsl_es(&glsl_es::ATMOSPHERE),
};

/// A layer drawn into a texture, composited onto the frame.
pub static LAYER_COMPOSITE: Program = Program {
    name: "LayerCompositeShader",
    buffers: &[ProgramBuffer::uniform::<LayerCompositeUBO>("props", 0, Stages::Fragment)],
    paint_params: None,
    projection: Projection::None,
    attributes: &[POS],
    instance_attributes: &[],
    textures: &[
        ProgramTexture::texels("image", Stages::Fragment),
        ProgramTexture::texels("backdrop", Stages::Fragment),
    ],
    properties: &[],
    sources: Sources::NONE
        .wgsl(&wgsl::LAYER_COMPOSITE)
        .msl(&msl::LAYER_COMPOSITE)
        .glsl(&glsl::LAYER_COMPOSITE)
        .glsl_es(&glsl_es::LAYER_COMPOSITE),
};