2021-05-08 20:09:28 +00:00
|
|
|
// Vertex shader
|
|
|
|
|
|
|
|
struct VertexOutput {
|
2022-07-01 23:00:19 +00:00
|
|
|
@builtin(position) clip_position: vec4<f32>,
|
2021-05-08 20:09:28 +00:00
|
|
|
};
|
|
|
|
|
2022-07-01 23:00:19 +00:00
|
|
|
@vertex
|
2021-10-27 10:58:05 +00:00
|
|
|
fn vs_main(
|
2022-07-01 23:00:19 +00:00
|
|
|
@builtin(vertex_index) in_vertex_index: u32,
|
2021-05-08 20:09:28 +00:00
|
|
|
) -> VertexOutput {
|
|
|
|
var out: VertexOutput;
|
|
|
|
let x = f32(1 - i32(in_vertex_index)) * 0.5;
|
|
|
|
let y = f32(i32(in_vertex_index & 1u) * 2 - 1) * 0.5;
|
|
|
|
out.clip_position = vec4<f32>(x, y, 0.0, 1.0);
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Fragment shader
|
|
|
|
|
2022-07-01 23:00:19 +00:00
|
|
|
@fragment
|
|
|
|
fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {
|
2021-05-08 20:09:28 +00:00
|
|
|
return vec4<f32>(0.3, 0.2, 0.1, 1.0);
|
|
|
|
}
|