Skip to content

Instantly share code, notes, and snippets.

@boyswan
Last active October 24, 2022 19:12
Show Gist options
  • Select an option

  • Save boyswan/d521f3a944e7004d328a22fe811f1bd6 to your computer and use it in GitHub Desktop.

Select an option

Save boyswan/d521f3a944e7004d328a22fe811f1bd6 to your computer and use it in GitHub Desktop.
wgpu
// 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment