1// Vertex shader for cube-texture reflection mapping
2// Brian Paul
3
4
5varying vec3 normal;
6
7void main() 
8{
9   vec3 n = gl_NormalMatrix * gl_Normal;
10   vec3 u = normalize(vec3(gl_ModelViewMatrix * gl_Vertex));
11   float two_n_dot_u = 2.0 * dot(n, u);
12   vec4 f;
13   f.xyz = u - n * two_n_dot_u;
14   f.w = 1.0;
15
16   // outputs
17   normal = n;
18   gl_TexCoord[0] = gl_TextureMatrix[0] * f;
19   gl_Position = ftransform();
20}
21