2021-06-06 11:40:33 +10:00
|
|
|
// Vertex shader bindings
|
|
|
|
|
|
|
|
struct VertexOutput {
|
|
|
|
[[location(0)]] tex_coord: vec2<f32>;
|
|
|
|
[[builtin(position)]] position: vec4<f32>;
|
|
|
|
};
|
|
|
|
|
|
|
|
[[block]] struct Locals {
|
|
|
|
transform: mat4x4<f32>;
|
|
|
|
};
|
|
|
|
[[group(0), binding(2)]] var r_locals: Locals;
|
|
|
|
|
|
|
|
[[stage(vertex)]]
|
2021-06-28 04:09:29 +10:00
|
|
|
fn vs_main(
|
|
|
|
[[location(0)]] position: vec2<f32>,
|
|
|
|
[[location(1)]] tex_coord: vec2<f32>,
|
|
|
|
) -> VertexOutput {
|
2021-06-06 11:40:33 +10:00
|
|
|
var out: VertexOutput;
|
2021-06-28 04:09:29 +10:00
|
|
|
out.tex_coord = tex_coord;
|
|
|
|
out.position = r_locals.transform * vec4<f32>(position, 0.0, 1.0);
|
2021-06-06 11:40:33 +10:00
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Fragment shader bindings
|
|
|
|
|
|
|
|
[[group(0), binding(0)]] var r_tex_color: texture_2d<f32>;
|
|
|
|
[[group(0), binding(1)]] var r_tex_sampler: sampler;
|
|
|
|
|
|
|
|
[[stage(fragment)]]
|
|
|
|
fn fs_main([[location(0)]] tex_coord: vec2<f32>) -> [[location(0)]] vec4<f32> {
|
|
|
|
return textureSample(r_tex_color, r_tex_sampler, tex_coord);
|
|
|
|
}
|