diff options
Diffstat (limited to 'games/00_triangle/src/shader.wgsl')
| -rw-r--r-- | games/00_triangle/src/shader.wgsl | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/games/00_triangle/src/shader.wgsl b/games/00_triangle/src/shader.wgsl new file mode 100644 index 0000000..9ff0e3f --- /dev/null +++ b/games/00_triangle/src/shader.wgsl @@ -0,0 +1,19 @@ +// Vertex shader + +struct VertexOutput { + @builtin(position) clip_position : vec4<f32>, +}; + +@vertex fn vs_main(@builtin(vertex_index) in_vertex_index : u32, ) + -> 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 +@fragment fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> { + return vec4<f32>(0.3, 0.2, 0.1, 1.0); +} |
