Last active
October 24, 2022 19:12
-
-
Save boyswan/d521f3a944e7004d328a22fe811f1bd6 to your computer and use it in GitHub Desktop.
Revisions
-
boyswan revised this gist
Oct 24, 2022 . 1 changed file with 12 additions and 12 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,24 +1,24 @@ // I set up my mesh and insert my custom attribute with an empty value pub const ATTRIBUTE_FRAME: MeshVertexAttribute = MeshVertexAttribute::new("frame", 988540917, VertexFormat::Float32x2); let mut mesh = Mesh::from(shape::Quad::new(Vec2::splat(48.0))); let empty: Vec<[f32; 2]> = vec![[0.0; 2]; 4]; mesh.insert_attribute(ATTRIBUTE_FRAME, empty); // Add attribute with batched values in batch loop if let Ok(mesh_handle) = mesh_handles.get(batcher) { if let Some(mesh) = meshes.get_mut(&mesh_handle.0) { mesh.insert_attribute(Mesh::ATTRIBUTE_POSITION, batch.positions.to_owned()); mesh.insert_attribute(Mesh::ATTRIBUTE_NORMAL, batch.normals.to_owned()); mesh.insert_attribute(Mesh::ATTRIBUTE_UV_0, batch.uvs.to_owned()); mesh.insert_attribute(ATTRIBUTE_FRAME, batch.frames.to_owned()); mesh.set_indices(Some(Indices::U16(batch.indices.to_owned()))); } }; //Update my material description and give attribuate a location fn specialize( descriptor: &mut RenderPipelineDescriptor, layout: &MeshVertexBufferLayout, -
boyswan revised this gist
Oct 24, 2022 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -34,7 +34,7 @@ fn specialize( descriptor.vertex.buffers = vec![vertex_layout]; } // try to access as argument @fragment fn fragment( @location(0) pos: vec4<f32>, -
boyswan revised this gist
Oct 24, 2022 . 1 changed file with 15 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,8 +7,16 @@ let empty: Vec<[f32; 2]> = vec![[0.0; 2]; 4]; mesh.insert_attribute(ATTRIBUTE_FRAME, empty); // Add attribute in batch loop if let Ok(mesh_handle) = mesh_handles.get(batcher) { if let Some(mesh) = meshes.get_mut(&mesh_handle.0) { mesh.insert_attribute(Mesh::ATTRIBUTE_POSITION, batch.positions.to_owned()); mesh.insert_attribute(Mesh::ATTRIBUTE_NORMAL, batch.normals.to_owned()); mesh.insert_attribute(Mesh::ATTRIBUTE_UV_0, batch.uvs.to_owned()); mesh.insert_attribute(ATTRIBUTE_FRAME, batch.frames.to_owned()); mesh.set_indices(Some(Indices::U16(batch.indices.to_owned()))); } }; //Update my material description fn specialize( @@ -38,7 +46,10 @@ fn fragment( } //However keep getting /* panicked at 'wgpu error: Validation Error Caused by: @@ -47,4 +58,5 @@ Caused by: error matching FRAGMENT shader requirements against the pipeline location[3] Float32x2 interpolated as Some(Perspective) with sampling Some(Center) is not provided by the previous stage outputs input is not provided by the earlier stage in the pipeline */
-
boyswan renamed this gist
Oct 24, 2022 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
boyswan created this gist
Oct 24, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,50 @@ // I set up my mesh and insert my custom attribute pub const ATTRIBUTE_FRAME: MeshVertexAttribute = MeshVertexAttribute::new("frame", 988540917, VertexFormat::Float32x2); let mut mesh = Mesh::from(shape::Quad::new(Vec2::splat(48.0))); let empty: Vec<[f32; 2]> = vec![[0.0; 2]; 4]; mesh.insert_attribute(ATTRIBUTE_FRAME, empty); ...inside batch mesh.insert_attribute(ATTRIBUTE_FRAME, batch.frames); //Update my material description fn specialize( descriptor: &mut RenderPipelineDescriptor, layout: &MeshVertexBufferLayout, _key: Material2dKey<Self>, ) -> Result<(), SpecializedMeshPipelineError> { ... let vertex_layout = layout.get_layout(&[ Mesh::ATTRIBUTE_POSITION.at_shader_location(0), Mesh::ATTRIBUTE_NORMAL.at_shader_location(1), Mesh::ATTRIBUTE_UV_0.at_shader_location(2), ATTRIBUTE_FRAME.at_shader_location(3), ])?; descriptor.vertex.buffers = vec![vertex_layout]; } @fragment fn fragment( @location(0) pos: vec4<f32>, @location(1) norm: vec3<f32>, @location(2) uv: vec2<f32>, @location(3) frame: vec2<f32> ) -> @location(0) vec4<f32> { ... } However keep getting panicked at 'wgpu error: Validation Error Caused by: In Device::create_render_pipeline note: label = `transparent_mesh2d_pipeline` error matching FRAGMENT shader requirements against the pipeline location[3] Float32x2 interpolated as Some(Perspective) with sampling Some(Center) is not provided by the previous stage outputs input is not provided by the earlier stage in the pipeline