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