uniform mat4 tmpMat; //cancels out the effect of the VIEW matrix (so only MODEL matrix remains active) ==> all in all transform the vertex to WORLDSPACE

uniform sampler2D noiseMap;

uniform float texW;
uniform float texH;

uniform vec4 camPos;

uniform vec4 trans;
uniform vec4 scale;

varying vec2 tc;

uniform vec2 texLookupScale;

varying float vertex_height;

varying vec4 shadow_tex_coord;

varying vec3 V;
varying vec3 L;

uniform vec3 lightDir;

void main() 
{
  //  tc = gl_Vertex.xz;
  tc = gl_Vertex.xz * texLookupScale;

  vec4 transformed_vertex = gl_Vertex; //(gl_Vertex+trans)*scale;




  //  vertex_height = (gl_Vertex.y+trans.y)*scale.y;
  vertex_height = transformed_vertex.y;

  //   V = transformed_vertex.xyz - camPos.xyz;
  //vec4 eyeVertex = gl_ModelViewMatrix * transformed_vertex;
  //vec3 eyeView = -normalize(eyeVertex.xyz);
//
 V = normalize(tmpMat * -normalize(gl_ModelViewMatrix * transformed_vertex)).xyz;
  //done in FS anyway  V = normalize(V);

 L = normalize(lightDir).xyz;


  shadow_tex_coord = gl_TextureMatrix[2] * transformed_vertex;

  gl_Position = gl_ModelViewProjectionMatrix * transformed_vertex;

  gl_ClipVertex = gl_ModelViewMatrix * transformed_vertex;

  //gl_TexCoord[4].q = ComputeCameraDepth(transformed_vertex);
  //!
 gl_TexCoord[4].q = gl_Position.z;
  //gl_TexCoord[4].q = gl_Position.z / gl_Position.w;
  //gl_TexCoord[4].q = gl_Position.z;
  //gl_TexCoord[4].q = gl_Position.z * gl_Position.w;

}
