diff options
Diffstat (limited to 'client/src/scene_render.rs')
-rw-r--r-- | client/src/scene_render.rs | 55 |
1 files changed, 32 insertions, 23 deletions
diff --git a/client/src/scene_render.rs b/client/src/scene_render.rs index 047cee4..f6f7dbb 100644 --- a/client/src/scene_render.rs +++ b/client/src/scene_render.rs @@ -35,20 +35,6 @@ pub struct ScenePipeline { pipeline: RenderPipeline, } -macro_rules! v_attr { - ($($n:literal),*) => { - [$(VertexBufferLayout { - step_mode: VertexStepMode::Vertex, - array_stride: 4, - attributes: &[VertexAttribute { - format: VertexFormat::Float32, - offset: 0, - shader_location: $n, - }], - }),*] - }; -} - impl ScenePipeline { pub fn new(device: &Device, format: TextureFormat) -> (Self, BindGroupLayout) { let module = device.create_shader_module(include_wgsl!("shader.wgsl")); @@ -98,7 +84,35 @@ impl ScenePipeline { vertex: VertexState { module: &module, entry_point: Some("vs_main"), - buffers: &v_attr!(0, 1, 2, 3, 4, 5, 6, 7), + buffers: &[ + VertexBufferLayout { + step_mode: VertexStepMode::Vertex, + array_stride: 3 * size_of::<f32>() as u64, + attributes: &[VertexAttribute { + format: VertexFormat::Float32x3, + offset: 0, + shader_location: 0, + }], + }, + VertexBufferLayout { + step_mode: VertexStepMode::Vertex, + array_stride: 3 * size_of::<f32>() as u64, + attributes: &[VertexAttribute { + format: VertexFormat::Float32x3, + offset: 0, + shader_location: 1, + }], + }, + VertexBufferLayout { + step_mode: VertexStepMode::Vertex, + array_stride: 2 * size_of::<f32>() as u64, + attributes: &[VertexAttribute { + format: VertexFormat::Float32x2, + offset: 0, + shader_location: 2, + }], + }, + ], compilation_options: PipelineCompilationOptions::default(), }, primitive: PrimitiveState { @@ -177,14 +191,9 @@ impl ScenePipeline { rpass.set_pipeline(&self.pipeline); rpass.set_push_constants(ShaderStages::VERTEX, 0, projection.as_flattened()); rpass.set_index_buffer(part.index.slice(..), IndexFormat::Uint16); - rpass.set_vertex_buffer(0, part.position[0].slice(..)); - rpass.set_vertex_buffer(1, part.position[1].slice(..)); - rpass.set_vertex_buffer(2, part.position[2].slice(..)); - rpass.set_vertex_buffer(3, part.normal[0].slice(..)); - rpass.set_vertex_buffer(4, part.normal[1].slice(..)); - rpass.set_vertex_buffer(5, part.normal[2].slice(..)); - rpass.set_vertex_buffer(6, part.texcoord[0].slice(..)); - rpass.set_vertex_buffer(7, part.texcoord[1].slice(..)); + rpass.set_vertex_buffer(0, part.position.slice(..)); + rpass.set_vertex_buffer(1, part.normal.slice(..)); + rpass.set_vertex_buffer(2, part.texcoord.slice(..)); rpass.draw_indexed(0..part.index_count, 0, 0..1); } } |