rustial-renderer-wgpu 1.0.0

Pure WGPU renderer for the rustial 2.5D map engine
Documentation
//! Vertex type for heatmap point rendering.

use bytemuck::{Pod, Zeroable};

/// A vertex for the heatmap GPU pipeline.
///
/// Each heatmap point is rendered as a screen-aligned quad.  The fragment
/// shader accumulates Gaussian weight contributions into a framebuffer
/// which is then colour-mapped in a second pass.
#[repr(C)]
#[derive(Debug, Clone, Copy, Pod, Zeroable)]
pub struct HeatmapVertex {
    /// Point centre position `[x, y, z]` in camera-relative meters.
    pub position: [f32; 3],
    /// Quad corner offset `[u, v]` in `[-1..1]` range.
    pub quad_offset: [f32; 2],
    /// Heatmap parameters: `[weight, radius, intensity, 0]`.
    pub params: [f32; 4],
}

impl HeatmapVertex {
    /// Vertex buffer layout for the heatmap pipeline.
    pub fn layout() -> wgpu::VertexBufferLayout<'static> {
        wgpu::VertexBufferLayout {
            array_stride: std::mem::size_of::<HeatmapVertex>() as wgpu::BufferAddress,
            step_mode: wgpu::VertexStepMode::Vertex,
            attributes: &[
                // position
                wgpu::VertexAttribute {
                    offset: 0,
                    shader_location: 0,
                    format: wgpu::VertexFormat::Float32x3,
                },
                // quad_offset
                wgpu::VertexAttribute {
                    offset: 12,
                    shader_location: 1,
                    format: wgpu::VertexFormat::Float32x2,
                },
                // params (weight, radius, intensity, 0)
                wgpu::VertexAttribute {
                    offset: 20,
                    shader_location: 2,
                    format: wgpu::VertexFormat::Float32x4,
                },
            ],
        }
    }
}