1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
|
| @vertex
| fn vs_main(@builtin(vertex_index) vertex_index: u32) -> @builtin(position) vec4f {
| let pos = array<vec2f, 3>(
| vec2f(-0.5, -0.5),
| vec2f( 0.5, -0.5),
| vec2f( 0.0, 0.5)
| );
| return vec4f(pos[vertex_index], 0.0, 1.0);
| }
|
|
| fn get_triangle_color(index: u32) -> vec4f {
| let colors = array<vec4f, 3>(
| vec4f(1.0, 0.0, 0.0, 1.0),
| vec4f(0.0, 1.0, 0.0, 1.0),
| vec4f(0.0, 0.0, 1.0, 1.0)
| );
| return colors[index % 3u];
| }
|
|
| @fragment
| fn fs_main() -> @location(0) vec4f {
| return vec4f(1.0, 0.0, 0.0, 1.0);
| }
|
|