struct VertexInput { // @location(0) pos: vec2, // @location(1) uv: vec2, // @location(2) col: vec4, [[location(0)]] pos: vec2; [[location(1)]] uv: vec2; [[location(2)]] col: vec4; }; struct FragmentInput { // @builtin(position) pos: vec4, // @location(0) col: vec4, // @location(1) uv: vec2, [[builtin(position)]] pos: vec4; [[location(0)]] col: vec4; [[location(1)]] uv: vec2; }; struct UniformInput { mvp: mat4x4; }; // @group(0) // @binding(0) [[group(0), binding(0)]] var ubo: UniformInput; // @group(0) // @binding(1) [[group(0), binding(1)]] var t_texture: texture_2d; // @group(0) // @binding(2) [[group(0), binding(2)]] var s_texture: sampler; // @vertex [[stage(vertex)]] fn vs_main(vin: VertexInput) -> FragmentInput { var fin: FragmentInput; fin.pos = ubo.mvp * vec4(vin.pos, 0.0, 1.0); fin.col = vin.col; fin.uv = vin.uv; return fin; } // @fragment [[stage(fragment)]] fn fs_main(fin: FragmentInput) -> [[location(0)]] vec4 { // @location(0) let alpha = textureSample(t_texture, s_texture, fin.uv).x; return fin.col * vec4(1.0, 1.0, 1.0, alpha); }