From 1c4a6538cb0c5ffcfd94154cf52371d0e3ef7849 Mon Sep 17 00:00:00 2001 From: mars Date: Sat, 7 May 2022 18:57:31 -0600 Subject: [PATCH] Use only skinning data for vertices --- shaders/mesh_forward.wgsl | 6 ++---- src/pass/mesh.rs | 10 +++++----- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/shaders/mesh_forward.wgsl b/shaders/mesh_forward.wgsl index ffba437..d4a8d89 100644 --- a/shaders/mesh_forward.wgsl +++ b/shaders/mesh_forward.wgsl @@ -5,13 +5,12 @@ struct CameraUniform { struct VertexInput { [[location(0)]] position: vec3; - [[location(1)]] color: vec3; + [[location(1)]] tan_frame: u32; }; struct VertexOutput { [[builtin(position)]] clip_position: vec4; [[location(0)]] position: vec3; - [[location(1)]] color: vec3; }; [[group(0), binding(0)]] @@ -28,7 +27,6 @@ fn vs_main( var out: VertexOutput; out.clip_position = camera.vp * vec4(world_pos, 1.0); out.position = world_pos; - out.color = vertex.color; return out; } @@ -36,5 +34,5 @@ fn vs_main( fn fs_main( frag: VertexOutput, ) -> [[location(0)]] vec4 { - return vec4(frag.color, 1.0); + return vec4(1.0); } diff --git a/src/pass/mesh.rs b/src/pass/mesh.rs index d011630..82276be 100644 --- a/src/pass/mesh.rs +++ b/src/pass/mesh.rs @@ -13,7 +13,7 @@ pub struct ShaderInfo { #[derive(Copy, Clone, bytemuck::Pod, bytemuck::Zeroable)] pub struct Vertex { pub position: [f32; 3], - pub color: [f32; 3], + pub tan_frame: u32, } impl Attribute for Vertex { @@ -23,7 +23,7 @@ impl Attribute for Vertex { } const VERTEX_ATTRS: &[wgpu::VertexAttribute] = - &wgpu::vertex_attr_array![0 => Float32x3, 1 => Float32x3]; + &wgpu::vertex_attr_array![0 => Float32x3, 1 => Uint32]; impl Vertex { pub fn desc() -> wgpu::VertexBufferLayout<'static> { @@ -81,15 +81,15 @@ impl MeshPass { let example_vertices = vec![ Vertex { position: [-0.5, 0.5, 0.0], - color: [1.0, 0.0, 0.0], + tan_frame: 0, }, Vertex { position: [0.5, 0.5, 0.0], - color: [0.0, 1.0, 0.0], + tan_frame: 0, }, Vertex { position: [0.0, -0.5, 0.0], - color: [0.0, 0.0, 1.0], + tan_frame: 0, }, ];