File: atmosphere_vs.glsl

package info (click to toggle)
ufoai-data 2.5-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 335,828 kB
  • ctags: 96
  • sloc: makefile: 192
file content (41 lines) | stat: -rw-r--r-- 984 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
 * @file
 * @brief Atmosphere vertex shader
 */

out_qualifier vec2 tex;

out_qualifier vec4 ambientLight;
out_qualifier vec4 diffuseLight;
out_qualifier vec4 specularLight;

out_qualifier vec3 lightVec;
out_qualifier vec3 eyeVec;

uniform vec2 UVSCALE;

void main() {
	gl_Position = ftransform();

	tex = gl_MultiTexCoord0.xy * UVSCALE;

	vec4 lightPos = gl_LightSource[0].position;
	ambientLight = gl_LightSource[0].ambient;
	diffuseLight = gl_LightSource[0].diffuse;
	specularLight = gl_LightSource[0].specular;

	vec3 t, b, n;
	n = normalize(gl_NormalMatrix * gl_Normal);
	t = normalize(cross(n, vec3(1.0, 0.0, 0.0)));
	b = normalize(cross(t, n));

	lightVec.x = dot(lightPos.rgb, t);
	lightVec.y = dot(lightPos.rgb, b);
	lightVec.z = dot(lightPos.rgb, n);

	/* estimate view vector (orthographic projection means we don't really have one) */
	vec4 view = vec4(0.0, 0.0, 100.0, 1.0);
	eyeVec.x = dot(view.xyz, t);
	eyeVec.y = dot(view.xyz, b);
	eyeVec.z = dot(view.xyz, n);
}