diff options
Diffstat (limited to 'src/shader.wgsl')
| -rw-r--r-- | src/shader.wgsl | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/shader.wgsl b/src/shader.wgsl index 9f158f1..c154cc4 100644 --- a/src/shader.wgsl +++ b/src/shader.wgsl @@ -1,10 +1,23 @@ +@group(0) @binding(0) var tex_sampler: sampler; +@group(0) @binding(1) var font_tex: texture_2d<f32>; + +struct VertexOutput { + @builtin(position) position: vec4<f32>, + @location(0) uv: vec2<f32>, +} + @vertex -fn vs_main(@builtin(vertex_index) in_vertex_index: u32) -> @builtin(position) vec4<f32> { +fn vs_main(@builtin(vertex_index) in_vertex_index: u32) -> VertexOutput { let uv = vec2<f32>(f32((in_vertex_index << 1) & 2), f32(in_vertex_index & 2)) / 2.0; - return vec4<f32>(uv.x - 0.5, uv.y - 0.5, 0.0, 1.0); + + var out: VertexOutput; + out.position = vec4<f32>(uv.x - 0.5, uv.y - 0.5, 0.0, 1.0); + out.uv = uv; + + return out; } @fragment -fn fs_main() -> @location(0) vec4<f32> { - return vec4<f32>(1.0, 1.0, 1.0, 1.0); +fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> { + return vec4<f32>(1.0, 1.0, 1.0, textureSample(font_tex, tex_sampler, in.uv).r); } |
