rustial-renderer-wgpu 0.0.1

Pure WGPU renderer for the rustial 2.5D map engine
Documentation
//! Vertex type for fill-pattern rendering (position + colour + pattern UV).

use bytemuck::{Pod, Zeroable};

/// A vertex for the fill-pattern GPU pipeline.
///
/// Extends [`super::fill_vertex::FillVertex`] with per-vertex UV
/// coordinates used to sample the repeating pattern texture.
#[repr(C)]
#[derive(Debug, Clone, Copy, Pod, Zeroable)]
pub struct FillPatternVertex {
    /// Position `[x, y, z]` in camera-relative meters.
    pub position: [f32; 3],
    /// Per-vertex RGBA color (used as fallback / tint).
    pub color: [f32; 4],
    /// Pattern UV coordinates.
    ///
    /// Values outside `[0, 1]` repeat via the GPU sampler's `Repeat`
    /// address mode.  UV = world_position / pattern_size.
    pub uv: [f32; 2],
}

impl FillPatternVertex {
    /// Vertex buffer layout for the fill-pattern pipeline.
    pub fn layout() -> wgpu::VertexBufferLayout<'static> {
        wgpu::VertexBufferLayout {
            array_stride: std::mem::size_of::<FillPatternVertex>() as wgpu::BufferAddress,
            step_mode: wgpu::VertexStepMode::Vertex,
            attributes: &[
                // position
                wgpu::VertexAttribute {
                    offset: 0,
                    shader_location: 0,
                    format: wgpu::VertexFormat::Float32x3,
                },
                // color
                wgpu::VertexAttribute {
                    offset: 12,
                    shader_location: 1,
                    format: wgpu::VertexFormat::Float32x4,
                },
                // uv
                wgpu::VertexAttribute {
                    offset: 28,
                    shader_location: 2,
                    format: wgpu::VertexFormat::Float32x2,
                },
            ],
        }
    }
}