/*
 * File: BasicPerlinNoiseShader.vert.txt
 * Shader for drawing of basic perlin noise 2D patches.
 *
 * This is the vertex shader. It takes the attributes (parameters)
 * provided by the Screen('DrawTexture(s)') command, performs some
 * basic calculations on it - the calculations that only need to be
 * done once per patch and that can be reliably carried out
 * at sufficient numeric precision in a vertex shader - then it passes
 * results of computations and other attributes as 'varying' parameters
 * to the fragment shader.
 *
 * (c) 2011-2012 Mario Kleiner. Licensed under MIT license.
 */

/* Attributes passed from Screen(): See the ProceduralShadingAPI.m file for infos: */
attribute vec4 sizeAngleFilterMode;
attribute vec4 modulateColor;
attribute vec4 auxParameters0;

/* Information passed to the fragment shader: */
varying vec4  baseColor;
varying float seed;
varying vec2  texSize;

void main()
{
    /* Apply standard geometric transformations to patch: */
    gl_Position = ftransform();

    /* Pass through texture coordinates: */
    gl_TexCoord[0] = gl_MultiTexCoord0;

    /* Contrast value is stored in auxParameters0[0]: */
    float Contrast = auxParameters0[0];

    /* Pass through random seed value from auxParameters0[1]: */
    seed = auxParameters0[1];

    /* Pass through reciprocal of size of the texture width x height = xy */
    texSize = 1.0 / sizeAngleFilterMode.xy;

    /* Premultiply the wanted Contrast to the color: */
    baseColor = modulateColor * Contrast;
}
