struct VertexOut {
  @builtin(position) pos: vec4<f32>, 
  @location(0) color: vec4<f32>,      
  @location(1) texcoord: vec2<f32>,
}

@vertex
fn VertexMain(
    @location(0) pos: vec2<f32>,
    @location(1) color: vec3<f32>,
    @location(2) texcoord: vec2<f32>,
    @builtin(vertex_index) vertexIndex: u32,
) -> VertexOut
{
    var output : VertexOut;
    output.pos = vec4<f32>(pos, 0.0, 1.0); 
    output.color = vec4<f32>(color, 1.0);     
    output.texcoord = vec2<f32>(texcoord);

    return output;
}

@group(0) @binding(0)
var texSampler : sampler;

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

@fragment
fn FragmentMain(fragData: VertexOut) -> @location(0) vec4<f32> 
{
    var texColor = textureSample(tex, texSampler, fragData.texcoord);
    return fragData.color * texColor;
}