2021-01-06 04:34:40 +00:00
|
|
|
// vertex
|
2023-01-12 17:26:28 +00:00
|
|
|
const c_scale: f32 = 1.2;
|
2021-03-07 05:03:05 +00:00
|
|
|
|
|
|
|
struct VertexOutput {
|
2022-03-12 21:48:10 +00:00
|
|
|
@location(0) uv : vec2<f32>,
|
|
|
|
@builtin(position) position : vec4<f32>,
|
2022-03-27 05:35:08 +00:00
|
|
|
}
|
2020-12-08 05:23:29 +00:00
|
|
|
|
2022-04-15 09:54:15 +00:00
|
|
|
@vertex
|
2021-11-26 18:56:59 +00:00
|
|
|
fn vert_main(
|
2022-01-19 15:33:06 +00:00
|
|
|
@location(0) pos : vec2<f32>,
|
|
|
|
@location(1) uv : vec2<f32>,
|
2021-04-22 02:38:26 +00:00
|
|
|
) -> 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
|
2022-01-19 15:33:06 +00:00
|
|
|
@group(0) @binding(0) var u_texture : texture_2d<f32>;
|
|
|
|
@group(0) @binding(1) var u_sampler : sampler;
|
2020-12-08 05:23:29 +00:00
|
|
|
|
2022-04-15 09:54:15 +00:00
|
|
|
@fragment
|
2022-01-19 15:33:06 +00:00
|
|
|
fn frag_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);
|
2022-02-15 10:05:21 +00:00
|
|
|
if color.a == 0.0 {
|
2021-03-11 06:04:55 +00:00
|
|
|
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
|
|
|
}
|
2021-06-24 10:59:35 +00:00
|
|
|
|
|
|
|
|
2023-01-12 17:26:28 +00:00
|
|
|
// We need to make sure that backends are successfully handling multiple entry points for the same shader stage.
|
2022-04-15 09:54:15 +00:00
|
|
|
@fragment
|
2022-01-19 15:33:06 +00:00
|
|
|
fn fs_extra() -> @location(0) vec4<f32> {
|
2021-06-24 11:01:41 +00:00
|
|
|
return vec4<f32>(0.0, 0.5, 0.0, 0.5);
|
|
|
|
}
|