1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//! Tile vertex definition.
use bytemuck::{Pod, Zeroable};
/// Vertex for tile quad rendering.
#[repr(C)]
#[derive(Debug, Clone, Copy, Pod, Zeroable)]
pub struct TileVertex {
/// Position `[x, y, z]` in camera-relative meters.
pub position: [f32; 3],
/// Texture coordinate `[u, v]`.
pub uv: [f32; 2],
/// Tile opacity used for fallback transition softening.
pub opacity: f32,
}
impl TileVertex {
/// Vertex buffer layout descriptor.
pub fn layout() -> wgpu::VertexBufferLayout<'static> {
wgpu::VertexBufferLayout {
array_stride: std::mem::size_of::<TileVertex>() as wgpu::BufferAddress,
step_mode: wgpu::VertexStepMode::Vertex,
attributes: &[
wgpu::VertexAttribute {
offset: 0,
shader_location: 0,
format: wgpu::VertexFormat::Float32x3,
},
wgpu::VertexAttribute {
offset: 12,
shader_location: 1,
format: wgpu::VertexFormat::Float32x2,
},
wgpu::VertexAttribute {
offset: 20,
shader_location: 2,
format: wgpu::VertexFormat::Float32,
},
],
}
}
}