struct Frame {
    clip_from_world: mat4x4<f32>,
    text_color:      vec4<f32>,
    pixels_per_mm:   f32,
    _pad0:           f32,
    _pad1:           f32,
    _pad2:           f32,
};

struct Vertex {
    @location(0) anchor_mm: vec2<f32>,
    @location(1) offset_px: vec2<f32>,
    @location(2) pick_id:   u32,
};

struct VsOut {
    @builtin(position) clip: vec4<f32>,
    @location(0) @interpolate(flat) pick_id: u32,
};

struct FsOut {
    @location(0) color:   vec4<f32>,
    @location(1) pick_id: u32,
};

@group(0) @binding(0) var<uniform> u: Frame;

@vertex
fn vs(in: Vertex) -> VsOut {
    let pos_mm = in.anchor_mm + in.offset_px / u.pixels_per_mm;
    let clip = u.clip_from_world * vec4<f32>(pos_mm, 0.0, 1.0);
    var out: VsOut;
    out.clip = clip;
    out.pick_id = in.pick_id;
    return out;
}

@fragment
fn fs(in: VsOut) -> FsOut {
    let c = u.text_color;
    var out: FsOut;
    out.color = vec4<f32>(c.rgb * c.a, c.a);
    out.pick_id = in.pick_id;
    return out;
}
