varying vec4 projPos;
varying float z;

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

vec3 shift = vec3( 0.0, 0.0, 0.0 );

void main()
{
  // set texture coords
  gl_TexCoord[0] = gl_MultiTexCoord0; // Color Map and normal map share coords
  
  // vertex in world
  vec4 vertex = gl_Vertex;
  
  // offset as billboard
  vertex.xyz += Scale * ( gl_TexCoord[0].t - 0.5 ) * UpVector;
  vertex.xyz += Scale * ( gl_TexCoord[0].s - 0.5 ) * RightVector;
  
  // position in view and projection
  projPos = gl_ModelViewProjectionMatrix * vertex;
  z = length((gl_ModelViewMatrix * vertex).xyz);
  
  // output transformed
  gl_Position = projPos;
}