Use only skinning data for vertices

This commit is contained in:
mars 2022-05-07 18:57:31 -06:00
parent 49cda13e50
commit 1c4a6538cb
2 changed files with 7 additions and 9 deletions

View File

@ -5,13 +5,12 @@ struct CameraUniform {
struct VertexInput { struct VertexInput {
[[location(0)]] position: vec3<f32>; [[location(0)]] position: vec3<f32>;
[[location(1)]] color: vec3<f32>; [[location(1)]] tan_frame: u32;
}; };
struct VertexOutput { struct VertexOutput {
[[builtin(position)]] clip_position: vec4<f32>; [[builtin(position)]] clip_position: vec4<f32>;
[[location(0)]] position: vec3<f32>; [[location(0)]] position: vec3<f32>;
[[location(1)]] color: vec3<f32>;
}; };
[[group(0), binding(0)]] [[group(0), binding(0)]]
@ -28,7 +27,6 @@ fn vs_main(
var out: VertexOutput; var out: VertexOutput;
out.clip_position = camera.vp * vec4<f32>(world_pos, 1.0); out.clip_position = camera.vp * vec4<f32>(world_pos, 1.0);
out.position = world_pos; out.position = world_pos;
out.color = vertex.color;
return out; return out;
} }
@ -36,5 +34,5 @@ fn vs_main(
fn fs_main( fn fs_main(
frag: VertexOutput, frag: VertexOutput,
) -> [[location(0)]] vec4<f32> { ) -> [[location(0)]] vec4<f32> {
return vec4<f32>(frag.color, 1.0); return vec4<f32>(1.0);
} }

View File

@ -13,7 +13,7 @@ pub struct ShaderInfo {
#[derive(Copy, Clone, bytemuck::Pod, bytemuck::Zeroable)] #[derive(Copy, Clone, bytemuck::Pod, bytemuck::Zeroable)]
pub struct Vertex { pub struct Vertex {
pub position: [f32; 3], pub position: [f32; 3],
pub color: [f32; 3], pub tan_frame: u32,
} }
impl Attribute for Vertex { impl Attribute for Vertex {
@ -23,7 +23,7 @@ impl Attribute for Vertex {
} }
const VERTEX_ATTRS: &[wgpu::VertexAttribute] = const VERTEX_ATTRS: &[wgpu::VertexAttribute] =
&wgpu::vertex_attr_array![0 => Float32x3, 1 => Float32x3]; &wgpu::vertex_attr_array![0 => Float32x3, 1 => Uint32];
impl Vertex { impl Vertex {
pub fn desc() -> wgpu::VertexBufferLayout<'static> { pub fn desc() -> wgpu::VertexBufferLayout<'static> {
@ -81,15 +81,15 @@ impl MeshPass {
let example_vertices = vec![ let example_vertices = vec![
Vertex { Vertex {
position: [-0.5, 0.5, 0.0], position: [-0.5, 0.5, 0.0],
color: [1.0, 0.0, 0.0], tan_frame: 0,
}, },
Vertex { Vertex {
position: [0.5, 0.5, 0.0], position: [0.5, 0.5, 0.0],
color: [0.0, 1.0, 0.0], tan_frame: 0,
}, },
Vertex { Vertex {
position: [0.0, -0.5, 0.0], position: [0.0, -0.5, 0.0],
color: [0.0, 0.0, 1.0], tan_frame: 0,
}, },
]; ];