2021-12-10 22:21:23 +00:00
|
|
|
struct View {
|
|
|
|
view_proj: mat4x4<f32>;
|
|
|
|
world_position: vec3<f32>;
|
|
|
|
};
|
|
|
|
[[group(0), binding(0)]]
|
|
|
|
var<uniform> view: View;
|
|
|
|
|
|
|
|
struct VertexOutput {
|
|
|
|
[[location(0)]] uv: vec2<f32>;
|
|
|
|
[[location(1)]] color: vec4<f32>;
|
|
|
|
[[builtin(position)]] position: vec4<f32>;
|
|
|
|
};
|
|
|
|
|
|
|
|
[[stage(vertex)]]
|
|
|
|
fn vertex(
|
|
|
|
[[location(0)]] vertex_position: vec3<f32>,
|
|
|
|
[[location(1)]] vertex_uv: vec2<f32>,
|
2022-04-25 13:54:50 +00:00
|
|
|
[[location(2)]] vertex_color: vec4<f32>,
|
2021-12-10 22:21:23 +00:00
|
|
|
) -> VertexOutput {
|
|
|
|
var out: VertexOutput;
|
|
|
|
out.uv = vertex_uv;
|
|
|
|
out.position = view.view_proj * vec4<f32>(vertex_position, 1.0);
|
2022-04-25 13:54:50 +00:00
|
|
|
out.color = vertex_color;
|
2021-12-10 22:21:23 +00:00
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
[[group(1), binding(0)]]
|
|
|
|
var sprite_texture: texture_2d<f32>;
|
|
|
|
[[group(1), binding(1)]]
|
|
|
|
var sprite_sampler: sampler;
|
|
|
|
|
|
|
|
[[stage(fragment)]]
|
|
|
|
fn fragment(in: VertexOutput) -> [[location(0)]] vec4<f32> {
|
|
|
|
var color = textureSample(sprite_texture, sprite_sampler, in.uv);
|
|
|
|
color = in.color * color;
|
|
|
|
return color;
|
|
|
|
}
|