uniform sampler2D noiseMap;

uniform float texW;
uniform float texH;

uniform vec4 trans;
uniform vec4 scale;

uniform float waveOff;

//
varying vec2 tc;
//varying vec2 tc_wavemodel;

//varying float vertex_height;
varying vec3 worldpos_vert;

varying vec4 shadow_tex_coord;


void main() 
{
  vec4 transformed_vertex;
  //
  tc = gl_Vertex.xz;
  /*
  vec4 ntrans = vec4(trans.x, trans.y, trans.z, trans.w);
  vec4 nscale = vec4(scale.x, scale.y, scale.z, scale.w);
  */
  //
   transformed_vertex = (gl_Vertex+trans)*scale;
  //  vec4 transformed_vertex = (gl_Vertex+ntrans)*nscale;

   //  tc_wavemodel = tmp_vert.xz;

   worldpos_vert.xz = transformed_vertex.xz;
   worldpos_vert.y = transformed_vertex.y;

   //   worldpos_vert.y -= waveOff;

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

  //  gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;

  //  gl_Position = gl_ModelViewProjectionMatrix * ((gl_Vertex+vec4(-0.5*texW/4.0, -10.0, -0.5*texH/4.0, 0.0))*vec4(30.0, 3.5, 30.0, 1.0));

  //  gl_Position = gl_ModelViewProjectionMatrix * ((gl_Vertex+vec4(-0.5*texW/4.0, -22.0, -0.5*texH/4.0, 0.0))*vec4(40.0, 3.5, 40.0, 1.0));
  //  gl_Position = gl_ModelViewProjectionMatrix * ((gl_Vertex+trans)*scale);

  ////  gl_Position = gl_ProjectionMatrixTranspose * gl_ModelViewMatrixTranspose * transformed_vertex;
  //gl_Position = gl_ModelViewProjectionMatrixInverse * transformed_vertex;
  //

   //   transformed_vertex.y = -transformed_vertex.y;
  shadow_tex_coord = gl_TextureMatrix[2] * transformed_vertex;
  //   transformed_vertex.y = -transformed_vertex.y;

  //  transformed_vertex = gl_ModelViewMatrix * tmp_vert;
  gl_Position = gl_ModelViewProjectionMatrix * transformed_vertex;

  //  gl_ClipVertex = gl_ModelViewMatrix * transformed_vertex;

  //  gl_Position += (-.5+texture2D(noiseMap, tc.xy*vec2(16.0/texW, 16.0/texH)))*vec4(.5, .5, .5, 1.0);
  //  gl_Position = ftransform();

  
}
