Skip to main content

rustial_renderer_wgpu/gpu/
heatmap_vertex.rs

1//! Vertex type for heatmap point rendering.
2
3use bytemuck::{Pod, Zeroable};
4
5/// A vertex for the heatmap GPU pipeline.
6///
7/// Each heatmap point is rendered as a screen-aligned quad.  The fragment
8/// shader accumulates Gaussian weight contributions into a framebuffer
9/// which is then colour-mapped in a second pass.
10#[repr(C)]
11#[derive(Debug, Clone, Copy, Pod, Zeroable)]
12pub struct HeatmapVertex {
13    /// Point centre position `[x, y, z]` in camera-relative meters.
14    pub position: [f32; 3],
15    /// Quad corner offset `[u, v]` in `[-1..1]` range.
16    pub quad_offset: [f32; 2],
17    /// Heatmap parameters: `[weight, radius, intensity, 0]`.
18    pub params: [f32; 4],
19}
20
21impl HeatmapVertex {
22    /// Vertex buffer layout for the heatmap pipeline.
23    pub fn layout() -> wgpu::VertexBufferLayout<'static> {
24        wgpu::VertexBufferLayout {
25            array_stride: std::mem::size_of::<HeatmapVertex>() as wgpu::BufferAddress,
26            step_mode: wgpu::VertexStepMode::Vertex,
27            attributes: &[
28                // position
29                wgpu::VertexAttribute {
30                    offset: 0,
31                    shader_location: 0,
32                    format: wgpu::VertexFormat::Float32x3,
33                },
34                // quad_offset
35                wgpu::VertexAttribute {
36                    offset: 12,
37                    shader_location: 1,
38                    format: wgpu::VertexFormat::Float32x2,
39                },
40                // params (weight, radius, intensity, 0)
41                wgpu::VertexAttribute {
42                    offset: 20,
43                    shader_location: 2,
44                    format: wgpu::VertexFormat::Float32x4,
45                },
46            ],
47        }
48    }
49}