Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'helix-ui/src/shader.wgsl')
| -rw-r--r-- | helix-ui/src/shader.wgsl | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/helix-ui/src/shader.wgsl b/helix-ui/src/shader.wgsl index a1ef447d..f8d654d7 100644 --- a/helix-ui/src/shader.wgsl +++ b/helix-ui/src/shader.wgsl @@ -1,11 +1,25 @@ + +// struct Vertex { +// [[location(0)]] position: vec2<f32>; +// }; + +struct View { + size: vec2<f32>; +}; + +[[group(0), binding(0)]] +var<uniform> view: View; + [[stage(vertex)]] -fn vs_main([[builtin(vertex_index)]] in_vertex_index: u32) -> [[builtin(position)]] vec4<f32> { - let x = f32(i32(in_vertex_index) - 1); - let y = f32(i32(in_vertex_index & 1u) * 2 - 1); - return vec4<f32>(x, y, 0.0, 1.0); +fn vs_main([[location(0)]] input: vec2<f32>) -> [[builtin(position)]] vec4<f32> { + // TODO: scale by hidpi factor? + return vec4<f32>( + input.xy / view.size.xy * 2.0 * 1.5, + 0.0, 1.0 + ); } [[stage(fragment)]] fn fs_main() -> [[location(0)]] vec4<f32> { - return vec4<f32>(1.0, 0.0, 0.0, 1.0); + return vec4<f32>(1.0, 1.0, 1.0, 1.0); } |