rustial_renderer_wgpu/gpu/fill_pattern_vertex.rs
1//! Vertex type for fill-pattern rendering (position + colour + pattern UV).
2
3use bytemuck::{Pod, Zeroable};
4
5/// A vertex for the fill-pattern GPU pipeline.
6///
7/// Extends [`super::fill_vertex::FillVertex`] with per-vertex UV
8/// coordinates used to sample the repeating pattern texture.
9#[repr(C)]
10#[derive(Debug, Clone, Copy, Pod, Zeroable)]
11pub struct FillPatternVertex {
12 /// Position `[x, y, z]` in camera-relative meters.
13 pub position: [f32; 3],
14 /// Per-vertex RGBA color (used as fallback / tint).
15 pub color: [f32; 4],
16 /// Pattern UV coordinates.
17 ///
18 /// Values outside `[0, 1]` repeat via the GPU sampler's `Repeat`
19 /// address mode. UV = world_position / pattern_size.
20 pub uv: [f32; 2],
21}
22
23impl FillPatternVertex {
24 /// Vertex buffer layout for the fill-pattern pipeline.
25 pub fn layout() -> wgpu::VertexBufferLayout<'static> {
26 wgpu::VertexBufferLayout {
27 array_stride: std::mem::size_of::<FillPatternVertex>() as wgpu::BufferAddress,
28 step_mode: wgpu::VertexStepMode::Vertex,
29 attributes: &[
30 // position
31 wgpu::VertexAttribute {
32 offset: 0,
33 shader_location: 0,
34 format: wgpu::VertexFormat::Float32x3,
35 },
36 // color
37 wgpu::VertexAttribute {
38 offset: 12,
39 shader_location: 1,
40 format: wgpu::VertexFormat::Float32x4,
41 },
42 // uv
43 wgpu::VertexAttribute {
44 offset: 28,
45 shader_location: 2,
46 format: wgpu::VertexFormat::Float32x2,
47 },
48 ],
49 }
50 }
51}