Skip to content

Commit

Permalink
fix mesh2d_manual example
Browse files Browse the repository at this point in the history
  • Loading branch information
awtterpip committed Oct 12, 2024
1 parent 992d17b commit 6c4476c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions examples/2d/mesh2d_manual.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ impl SpecializedRenderPipeline for ColoredMesh2dPipeline {
// Position
VertexFormat::Float32x3,
// Color
VertexFormat::Uint32,
VertexFormat::Float32x4,
];

let vertex_layout =
Expand Down Expand Up @@ -246,7 +246,7 @@ const COLORED_MESH2D_SHADER: &str = r"
struct Vertex {
@builtin(instance_index) instance_index: u32,
@location(0) position: vec3<f32>,
@location(1) color: u32,
@location(1) color: vec4<f32>,
};
struct VertexOutput {
Expand All @@ -264,7 +264,7 @@ fn vertex(vertex: Vertex) -> VertexOutput {
let model = mesh2d_functions::get_world_from_local(vertex.instance_index);
out.clip_position = mesh2d_functions::mesh2d_position_local_to_clip(model, vec4<f32>(vertex.position, 1.0));
// Unpack the `u32` from the vertex buffer into the `vec4<f32>` used by the fragment shader
out.color = vec4<f32>((vec4<u32>(vertex.color) >> vec4<u32>(0u, 8u, 16u, 24u)) & vec4<u32>(255u)) / 255.0;
out.color = vertex.color;
return out;
}
Expand Down

0 comments on commit 6c4476c

Please sign in to comment.