~starkingdoms/starkingdoms

ref: e54fae7165cfad2269e971159960a03285d9d25a starkingdoms/crates/client/src/shaders/text_quad_mips.wgsl -rw-r--r-- 777 bytes
e54fae71 — ghostly_zsh client networking probably working 10 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
struct VertexOutput {
    @builtin(position) position: vec4<f32>,
    @location(0) texcoord: vec2<f32>
}
@vertex fn vs(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput {
    let pos = array(
        vec2<f32>(0.0, 0.0),
        vec2<f32>(1.0, 0.0),
        vec2<f32>(0.0, 1.0),
        vec2<f32>(0.0, 1.0),
        vec2<f32>(1.0, 0.0),
        vec2<f32>(1.0, 1.0)
    );
    var out: VertexOutput;
    let xy = pos[vertexIndex];
    out.position = vec4<f32>(xy * 2.0 - 1.0, 0.0, 1.0);
    out.texcoord = vec2<f32>(xy.x, 1.0 - xy.y);
    return out;
}

@group(0) @binding(0) var texSampler: sampler;
@group(0) @binding(1) var tex: texture_2d<f32>;

@fragment fn fs(inp: VertexOutput) -> @location(0) vec4<f32> {
    return textureSample(tex, texSampler, inp.texcoord);
}