struct Uniforms { screen: vec2, _pad: vec2, }; @group(0) @binding(0) var u: Uniforms; @group(0) @binding(1) var samp: sampler; @group(0) @binding(2) var tex: texture_2d; struct VsIn { @location(0) pos: vec2, @location(1) uv: vec2, @location(2) color: vec4, }; struct VsOut { @builtin(position) pos: vec4, @location(0) uv: vec2, @location(1) color: vec4, }; @vertex fn vs_main(input: VsIn) -> VsOut { var out: VsOut; let ndc = vec2( (input.pos.x / u.screen.x) * 2.0 - 1.0, 1.0 - (input.pos.y / u.screen.y) * 2.0 ); out.pos = vec4(ndc, 0.0, 1.0); out.uv = input.uv; out.color = input.color; return out; } @fragment fn fs_main(input: VsOut) -> @location(0) vec4 { let a = textureSample(tex, samp, input.uv).r; return vec4(input.color.rgb, input.color.a * a); }