2021-01-06 04:34:40 +00:00
|
|
|
// vertex
|
2021-04-11 04:35:03 +00:00
|
|
|
let c_scale: f32 = 1.2;
|
2021-03-07 05:03:05 +00:00
|
|
|
|
|
|
|
struct VertexOutput {
|
|
|
|
[[location(0)]] uv : vec2<f32>;
|
|
|
|
[[builtin(position)]] position : vec4<f32>;
|
|
|
|
};
|
2020-12-08 05:23:29 +00:00
|
|
|
|
|
|
|
[[stage(vertex)]]
|
2021-04-22 02:38:26 +00:00
|
|
|
fn main(
|
|
|
|
[[location(0)]] pos : vec2<f32>,
|
|
|
|
[[location(1)]] uv : vec2<f32>,
|
|
|
|
) -> VertexOutput {
|
2021-04-17 05:14:07 +00:00
|
|
|
return VertexOutput(uv, vec4<f32>(c_scale * pos, 0.0, 1.0));
|
2020-12-08 05:23:29 +00:00
|
|
|
}
|
|
|
|
|
2021-01-06 04:34:40 +00:00
|
|
|
// fragment
|
2020-12-11 06:45:28 +00:00
|
|
|
[[group(0), binding(0)]] var u_texture : texture_2d<f32>;
|
2020-12-08 05:23:29 +00:00
|
|
|
[[group(0), binding(1)]] var u_sampler : sampler;
|
|
|
|
|
|
|
|
[[stage(fragment)]]
|
2021-03-07 05:03:05 +00:00
|
|
|
fn main([[location(0)]] uv : vec2<f32>) -> [[location(0)]] vec4<f32> {
|
2021-04-11 04:35:03 +00:00
|
|
|
let color = textureSample(u_texture, u_sampler, uv);
|
2021-03-11 06:04:55 +00:00
|
|
|
if (color.a == 0.0) {
|
|
|
|
discard;
|
|
|
|
}
|
2021-03-15 05:24:40 +00:00
|
|
|
// forcing the expression here to be emitted in order to check the
|
|
|
|
// uniformity of the control flow a bit more strongly.
|
2021-04-11 04:35:03 +00:00
|
|
|
let premultiplied = color.a * color;
|
2021-03-07 05:03:05 +00:00
|
|
|
return premultiplied;
|
2020-12-08 05:23:29 +00:00
|
|
|
}
|