UFO: Alien Invasion
atmosphere_vs.glsl
Go to the documentation of this file.
1 /**
2  * @file
3  * @brief Atmosphere vertex shader
4  */
5 
6 out_qualifier vec2 tex;
7 
8 out_qualifier vec4 ambientLight;
9 out_qualifier vec4 diffuseLight;
10 out_qualifier vec4 specularLight;
11 
12 out_qualifier vec3 lightVec;
13 out_qualifier vec3 eyeVec;
14 
15 uniform vec2 UVSCALE;
16 
17 void main() {
18  gl_Position = ftransform();
19 
20  tex = gl_MultiTexCoord0.xy * UVSCALE;
21 
22  vec4 lightPos = gl_LightSource[0].position;
23  ambientLight = gl_LightSource[0].ambient;
24  diffuseLight = gl_LightSource[0].diffuse;
25  specularLight = gl_LightSource[0].specular;
26 
27  vec3 t, b, n;
28  n = normalize(gl_NormalMatrix * gl_Normal);
29  t = normalize(cross(n, vec3(1.0, 0.0, 0.0)));
30  b = normalize(cross(t, n));
31 
32  lightVec.x = dot(lightPos.rgb, t);
33  lightVec.y = dot(lightPos.rgb, b);
34  lightVec.z = dot(lightPos.rgb, n);
35 
36  /* estimate view vector (orthographic projection means we don't really have one) */
37  vec4 view = vec4(0.0, 0.0, 100.0, 1.0);
38  eyeVec.x = dot(view.xyz, t);
39  eyeVec.y = dot(view.xyz, b);
40  eyeVec.z = dot(view.xyz, n);
41 }