struct Configuration { viewProj: mat4x4f, lightViewProj: mat4x4f, lightPosition: vec4f, eyePosition: vec4f, aspect: f32, }; struct GlyphBuffer { position: vec2f, size: vec2f, }; struct LayoutBuffer { position: vec4f, // glyph_index w }; @group(0) @binding(0) var config: Configuration; @group(1) @binding(0) var linearSampler: sampler; @group(1) @binding(1) var fontTexture: texture_2d; @group(1) @binding(2) var glyphBuffer: array; @group(2) @binding(0) var layoutBuffer: array; struct VertexInput { @builtin(vertex_index) vertex_index: u32, }; struct VertexOutput { @builtin(position) position: vec4f, @location(0) texture: vec2f, }; const vertices = array( vec2f(1.0, 0.0), vec2f(0.0, 1.0), vec2f(0.0, 0.0), vec2f(1.0, 1.0), ); @vertex fn vertexMain(input: VertexInput) -> VertexOutput { let texture = vertices[input.vertex_index]; let position = vec2f(texture.x, 1.0 - texture.y) * 2.0 - 1.0; var output: VertexOutput; output.position = vec4f(position * 0.5, 0.0, 1.0); output.texture = texture; return output; } @fragment fn fragmentMain(input: VertexOutput) -> @location(0) vec4f { var color = vec3f(input.texture.xy, 0); let p = glyphBuffer[66].position; let s = glyphBuffer[66].size; let base = textureSample(fontTexture, linearSampler, input.texture * s + p); let t = f32(base.x > 0.5); return vec4f(t, t, t, 1); }