summaryrefslogtreecommitdiffstats
path: root/examples/custom_shader/src/primitive/vertex.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/custom_shader/src/primitive/vertex.rs')
-rw-r--r--examples/custom_shader/src/primitive/vertex.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/examples/custom_shader/src/primitive/vertex.rs b/examples/custom_shader/src/primitive/vertex.rs
new file mode 100644
index 00000000..6d17aa0f
--- /dev/null
+++ b/examples/custom_shader/src/primitive/vertex.rs
@@ -0,0 +1,29 @@
+#[derive(Debug, Copy, Clone, bytemuck::Pod, bytemuck::Zeroable)]
+#[repr(C)]
+pub struct Vertex {
+ pub pos: glam::Vec3,
+ pub normal: glam::Vec3,
+ pub tangent: glam::Vec3,
+ pub uv: glam::Vec2,
+}
+
+impl Vertex {
+ const ATTRIBS: [wgpu::VertexAttribute; 4] = wgpu::vertex_attr_array![
+ //position
+ 0 => Float32x3,
+ //normal
+ 1 => Float32x3,
+ //tangent
+ 2 => Float32x3,
+ //uv
+ 3 => Float32x2,
+ ];
+
+ pub fn desc<'a>() -> wgpu::VertexBufferLayout<'a> {
+ wgpu::VertexBufferLayout {
+ array_stride: std::mem::size_of::<Self>() as wgpu::BufferAddress,
+ step_mode: wgpu::VertexStepMode::Vertex,
+ attributes: &Self::ATTRIBS,
+ }
+ }
+}