summaryrefslogtreecommitdiff
path: root/src/shader.wgsl
blob: c154cc433c1c26a9476f00975e68a4d5faec8381 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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) -> VertexOutput {
	let uv = vec2<f32>(f32((in_vertex_index << 1) & 2), f32(in_vertex_index & 2)) / 2.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(in: VertexOutput) -> @location(0) vec4<f32> {
	return vec4<f32>(1.0, 1.0, 1.0, textureSample(font_tex, tex_sampler, in.uv).r);
}