
#version 120

uniform mat4 gxl3d_ModelViewProjectionMatrix;
uniform mat4 gxl3d_ModelViewMatrix;

varying vec2 v_muv;

void main()
{
  vec4 p = vec4(gl_Vertex.xyz, 1.0);
  gl_Position = gxl3d_ModelViewProjectionMatrix * p;		
  //v_uv = gl_MultiTexCoord0;
  //v_normal = gxl3d_ModelMatrix * vec4(gl_Normal.xyz, 0.0);
  vec4 n = gxl3d_ModelViewMatrix * vec4(gl_Normal.xyz, 0.0);
	vec4 e = gxl3d_ModelViewMatrix * p; 
  vec3 r = reflect(normalize(e.xyz), normalize(n.xyz));

  float m = 2. * sqrt(pow(r.x, 2.) + pow(r.y, 2.) + pow(r.z + 1., 2.));  
  v_muv = r.xy / m + .5;
}

