mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-19 14:01:08 +01:00
34 lines
840 B
WebGPU Shading Language
34 lines
840 B
WebGPU Shading Language
// meant to be called with 3 vertex indices: 0, 1, 2
|
|
// draws one large triangle over the clip space like this:
|
|
// (the asterisks represent the clip space bounds)
|
|
//-1,1 1,1
|
|
// ---------------------------------
|
|
// | * .
|
|
// | * .
|
|
// | * .
|
|
// | * .
|
|
// | * .
|
|
// | * .
|
|
// |***************
|
|
// | . 1,-1
|
|
// | .
|
|
// | .
|
|
// | .
|
|
// | .
|
|
// |.
|
|
@vertex
|
|
fn vs_main(@builtin(vertex_index) vertex_index: u32) -> @builtin(position) vec4<f32> {
|
|
let x = i32(vertex_index) / 2;
|
|
let y = i32(vertex_index) & 1;
|
|
return vec4<f32>(
|
|
f32(x) * 4.0 - 1.0,
|
|
1.0 - f32(y) * 4.0,
|
|
0.0, 1.0
|
|
);
|
|
}
|
|
|
|
@fragment
|
|
fn fs_main() -> @location(0) vec4<f32> {
|
|
return vec4<f32>(1.0);
|
|
}
|