diff --git a/examples/lines.rs b/examples/lines.rs index 5880858..f335af1 100644 --- a/examples/lines.rs +++ b/examples/lines.rs @@ -96,7 +96,6 @@ impl GlassApp for LineApp { for line in lines { line_pipeline.draw( &mut rpass, - [0.0; 4], camera_projection([WIDTH as f32, HEIGHT as f32]).to_cols_array_2d(), line, ); diff --git a/src/pipelines/line/line.wgsl b/src/pipelines/line/line.wgsl index 872edb7..987c8ab 100644 --- a/src/pipelines/line/line.wgsl +++ b/src/pipelines/line/line.wgsl @@ -1,5 +1,4 @@ struct PushConstants { - view_pos: vec4, view_proj: mat4x4, start: vec4, end: vec4, @@ -23,13 +22,12 @@ fn vs_main( model: VertexInput, ) -> VertexOutput { var out: VertexOutput; - var pos = vec4(0.0); + var world_position = vec4(0.0); if (model.index == u32(0)) { - pos = pc.start; + world_position = pc.start; } else { - pos = pc.end; + world_position = pc.end; } - let world_position = pos + pc.view_pos; out.clip_position = pc.view_proj * world_position; out.color = pc.color; return out; diff --git a/src/pipelines/line/pipeline.rs b/src/pipelines/line/pipeline.rs index 7b0dcf2..44fe7ac 100644 --- a/src/pipelines/line/pipeline.rs +++ b/src/pipelines/line/pipeline.rs @@ -76,19 +76,13 @@ impl LinePipeline { pipeline } - pub fn draw<'r>( - &'r self, - rpass: &mut RenderPass<'r>, - view_pos: [f32; 4], - view_proj: [[f32; 4]; 4], - line: Line, - ) { + pub fn draw<'r>(&'r self, rpass: &mut RenderPass<'r>, view_proj: [[f32; 4]; 4], line: Line) { rpass.set_pipeline(&self.pipeline); rpass.set_vertex_buffer(0, self.vertices.slice(..)); rpass.set_push_constants( ShaderStages::VERTEX_FRAGMENT, 0, - bytemuck::cast_slice(&[LinePushConstants::new(view_pos, view_proj, line)]), + bytemuck::cast_slice(&[LinePushConstants::new(view_proj, line)]), ); rpass.draw(0..2, 0..1); } @@ -97,7 +91,6 @@ impl LinePipeline { #[repr(C)] #[derive(Copy, Clone, Pod, Zeroable)] pub struct LinePushConstants { - pub view_position: [f32; 4], pub view_proj: [[f32; 4]; 4], pub start: [f32; 4], pub end: [f32; 4], @@ -105,9 +98,8 @@ pub struct LinePushConstants { } impl LinePushConstants { - pub fn new(view_pos: [f32; 4], view_proj: [[f32; 4]; 4], line: Line) -> LinePushConstants { + pub fn new(view_proj: [[f32; 4]; 4], line: Line) -> LinePushConstants { LinePushConstants { - view_position: view_pos, view_proj, start: line.start.extend(1.0).to_array(), end: line.end.extend(1.0).to_array(), diff --git a/src/pipelines/quad/pipeline.rs b/src/pipelines/quad/pipeline.rs index 2c80f3e..56ea7c2 100644 --- a/src/pipelines/quad/pipeline.rs +++ b/src/pipelines/quad/pipeline.rs @@ -109,13 +109,13 @@ impl QuadPipeline { } pub fn push_constants( - view_position: [f32; 4], + quad_pos: [f32; 4], view_proj: [[f32; 4]; 4], quad_size: [f32; 2], aa_strength: f32, ) -> QuadPushConstants { QuadPushConstants { - view_position, + quad_pos, view_proj, dims: quad_size, aa_strength, @@ -150,7 +150,7 @@ impl QuadPipeline { &'r self, rpass: &mut RenderPass<'r>, bind_group: &'r BindGroup, - view_pos: [f32; 4], + quad_pos: [f32; 4], view_proj: [[f32; 4]; 4], quad_size: [f32; 2], aa_strength: f32, @@ -163,7 +163,7 @@ impl QuadPipeline { ShaderStages::VERTEX_FRAGMENT, 0, bytemuck::cast_slice(&[QuadPipeline::push_constants( - view_pos, + quad_pos, view_proj, quad_size, aa_strength, @@ -177,7 +177,7 @@ impl QuadPipeline { #[repr(C)] #[derive(Copy, Clone, Pod, Zeroable)] pub struct QuadPushConstants { - pub view_position: [f32; 4], + pub quad_pos: [f32; 4], pub view_proj: [[f32; 4]; 4], pub dims: [f32; 2], pub aa_strength: f32, diff --git a/src/pipelines/quad/quad.wgsl b/src/pipelines/quad/quad.wgsl index 879e810..49449f9 100644 --- a/src/pipelines/quad/quad.wgsl +++ b/src/pipelines/quad/quad.wgsl @@ -1,5 +1,5 @@ struct PushConstants { - view_pos: vec4, + quad_pos: vec4, view_proj: mat4x4, dims: vec2, aa_strength: f32, @@ -28,7 +28,7 @@ fn vs_main( // Scale vertices model.position + // Offset by pos - pc.view_pos; + pc.quad_pos; out.clip_position = pc.view_proj * world_position; out.color = model.color; return out;