-
Notifications
You must be signed in to change notification settings - Fork 1
/
tail.vert
74 lines (64 loc) · 1.78 KB
/
tail.vert
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#version 330
in vec3 position;
uniform float timer;
uniform vec3 rotation;
uniform vec3 translation;
mat4 view_frustum(float angle_of_view,
float aspect_ratio,
float z_near,
float z_far) {
return mat4(1.0/tan(angle_of_view), 0.0, 0.0, 0.0,
0.0, aspect_ratio/tan(angle_of_view), 0.0, 0.0,
0.0, 0.0, (z_far+z_near)/(z_far-z_near), 1.0,
0.0, 0.0, -2.0*z_far*z_near/(z_far-z_near), 0.0);
}
mat4 scale(float x, float y, float z) {
return mat4(x, 0.0, 0.0, 0.0,
0.0, y, 0.0, 0.0,
0.0, 0.0, z, 0.0,
0.0, 0.0, 0.0, 1.0);
}
mat4 translate(float x, float y, float z) {
return mat4(1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
x, y, z, 1.0);
}
mat4 rotate_x(float t) {
float ct = cos(t);
float st = sin(t);
return mat4(1.0, 0.0, 0.0, 0.0,
0.0, ct, st, 0.0,
0.0, -st, ct, 0.0,
0.0, 0.0, 0.0, 1.0);
}
mat4 rotate_y(float t) {
float st = sin(t);
float ct = cos(t);
return mat4(
vec4( ct, 0.0, st, 0.0),
vec4(0.0, 1.0, 0.0, 0.0),
vec4(-st, 0.0, ct, 0.0),
vec4(0.0, 0.0, 0.0, 1.0)
);
}
mat4 rotate_z(float t) {
float st = sin(t);
float ct = cos(t);
return mat4(
vec4( ct, st, 0.0, 0.0),
vec4(-st, ct, 0.0, 0.0),
vec4(0.0, 0.0, 1.0, 0.0),
vec4(0.0, 0.0, 0.0, 1.0)
);
}
void main() {
gl_Position = view_frustum(radians(45.0), 4.0/3.0, 0.0, 10.0)
* translate(translation.x, translation.y, translation.z)
* rotate_x(rotation.x)
* rotate_y(rotation.y)
* rotate_z(rotation.z)
* scale(1/25.0, 1.0/25.0, 1.0/25.0)
* vec4(position, 1.0);
// gl_PointSize = 160.0;
}