uniform vec4 camPos;
uniform float sc_ratio;

varying vec2 tc;
varying vec4 vertexPos;


varying vec4 tmp_pos;

varying vec3 eye2objW;
varying vec3 world_space_normal;

varying vec4 proj_tc_normals;

float ComputeCameraDepth(vec4 worldSpacePos)
{
  //
  vec4 viewPos = gl_ModelViewMatrix *  worldSpacePos;
  //vec4 viewPos = worldSpacePos;
  return viewPos.z;
}


void main() 
{
  tc = gl_Vertex.xz;
  vertexPos = gl_Vertex;


  //  gl_TexCoord[4].q = ComputeCameraDepth(vertexPos);


  gl_Position = tmp_pos = gl_ModelViewProjectionMatrix * gl_Vertex;

  gl_TexCoord[4].q = gl_Position.z;


  //calculate projective texture coords for
  //screen-aligned textures (reflection + refraction)
   vec4 vs;
   vs = vec4((tmp_pos.xyz+tmp_pos.w)*0.5, tmp_pos.w);
   tmp_pos = vs;
  



   ///  gl_Position = ftransform();
     gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;

     
     //     proj_tc_normals = gl_TextureMatrix[2] * gl_ClipVertex;
     //     proj_tc_normals = gl_TextureMatrix[2] * gl_Vertex;
     proj_tc_normals = gl_TextureMatrix[7] * gl_Vertex;



     eye2objW = normalize(gl_Vertex.xyz-camPos.xyz);
}
