/*
 * MelonJS Game Engine
 * Copyright (C) 2011 - 2015 Olivier Biot, Jason Oster, Aaron McLeod
 * http://www.melonjs.org
 *
 * WebGL Vertex shader for quad compositing
 */

precision highp float;


// Attributes

/**
 * Current vertex point
 * @ignore
 */
attribute vec2 aVertex;

/**
 * Vertex color
 * @ignore
 */
attribute vec4 aColor;

/**
 * Vertex texture unit index
 * Must be identical for all vertices in the quad
 * @ignore
 */
attribute float aTexture;

/**
 * Vertex texture coordinates
 * @ignore
 */
attribute vec2 aRegion;


// Uniforms

/**
 * Projection matrix
 * @ignore
 */
uniform mat3 uMatrix;


// Varyings

/**
 * Fragment color
 */
varying vec4 vColor;

/**
 * Fragment texture unit index
 * @ignore
 */
varying float vTexture;

/**
 * Fragment texture coordinates
 * @ignore
 */
varying vec2 vRegion;


void main(void) {
    // Transform the vertex position by the projection matrix
    gl_Position = vec4((uMatrix * vec3(aVertex, 1)).xy, 0, 1);

    // Pass the remaining attributes to the fragment shader
    vColor = aColor;
    vTexture = aTexture;
    vRegion = aRegion;
}

/*
 * MelonJS Game Engine
 * Copyright (C) 2011 - 2015 Olivier Biot, Jason Oster, Aaron McLeod
 * http://www.melonjs.org
 *
 * WebGL Vertex shader for quad compositing
 */

precision highp float;


// Attributes

/**
 * Current vertex point
 * @ignore
 */
attribute vec2 aVertex;

/**
 * Vertex color
 * @ignore
 */
attribute vec4 aColor;

/**
 * Vertex texture unit index
 * Must be identical for all vertices in the quad
 * @ignore
 */
attribute float aTexture;

/**
 * Vertex texture coordinates
 * @ignore
 */
attribute vec2 aRegion;


// Uniforms

/**
 * Projection matrix
 * @ignore
 */
uniform mat3 uMatrix;


// Varyings

/**
 * Fragment color
 */
varying vec4 vColor;

/**
 * Fragment texture unit index
 * @ignore
 */
varying float vTexture;

/**
 * Fragment texture coordinates
 * @ignore
 */
varying vec2 vRegion;


void main(void) {
    // Transform the vertex position by the projection matrix
    gl_Position = vec4((uMatrix * vec3(aVertex, 1)).xy, 0, 1);

    // Pass the remaining attributes to the fragment shader
    vColor = vec4(aColor.rgb * aColor.a, aColor.a);
    vTexture = aTexture;
    vRegion = aRegion;
}
