rustial-renderer-wgpu 1.0.0

Pure WGPU renderer for the rustial 2.5D map engine
Documentation
//! Shared reusable terrain grid vertex definition.

use bytemuck::{Pod, Zeroable};

/// Vertex for reusable terrain grids.
///
/// Carries only tile-local UV coordinates and a skirt flag. The final
/// world-space position is reconstructed in the shader from tile bounds and
/// GPU-sampled elevation data.
#[repr(C)]
#[derive(Debug, Clone, Copy, Pod, Zeroable)]
pub struct TerrainGridVertex {
    /// Tile-local UV in `[0, 1]`.
    pub uv: [f32; 2],
    /// `0.0` for surface vertices, `1.0` for skirt vertices.
    pub skirt: f32,
}

impl TerrainGridVertex {
    /// Vertex buffer layout descriptor.
    pub fn layout() -> wgpu::VertexBufferLayout<'static> {
        wgpu::VertexBufferLayout {
            array_stride: std::mem::size_of::<TerrainGridVertex>() as wgpu::BufferAddress,
            step_mode: wgpu::VertexStepMode::Vertex,
            attributes: &[
                wgpu::VertexAttribute {
                    offset: 0,
                    shader_location: 0,
                    format: wgpu::VertexFormat::Float32x2,
                },
                wgpu::VertexAttribute {
                    offset: 8,
                    shader_location: 1,
                    format: wgpu::VertexFormat::Float32,
                },
            ],
        }
    }
}