varying vec3 ViewPos;
varying vec4 projPos;

uniform float Scale;
uniform vec3 UpVector;
uniform vec3 RightVector;

void main()
{
  // set texture coords
  gl_TexCoord[0] = gl_MultiTexCoord0; // Color Map and normal map share coords
  
  vec4 vertex = gl_Vertex;
  vertex.xyz += Scale * ( gl_TexCoord[0].t - 0.5 ) * UpVector;
  vertex.xyz += Scale * ( gl_TexCoord[0].s - 0.5 ) * RightVector;
  
  // position
  ViewPos = (gl_ModelViewMatrix * vertex).xyz;
  projPos = gl_ModelViewProjectionMatrix * vertex;

  // Color
  gl_FrontColor = gl_Color;
  //gl_BackColor = gl_Color;

  // transform position
  gl_Position = gl_ModelViewProjectionMatrix * vertex;
}