-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vertex.txt
101 lines (66 loc) · 1.39 KB
/
Vertex.txt
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#version 430 core
const float PI= 22.0/7;
vec4 v_pos[4] =vec4[4](
vec4(0.1,-0.1,0,1),
vec4(0.1,0.1,0,1),
vec4(-0.1,-0.1,0,1),
vec4(-0.1,0.1,0,1)
);
vec2 t_pos[4]=vec2[4](
vec2(1,0),
vec2(1,1),
vec2(0,0),
vec2(0,1)
);
layout (location=0) in int i;//index of array to be used is sent via uniform
struct st_live
{
vec3 offset;
float pad1;
vec3 scale;
float pad2;
float ang;
float pad3;
float pad4;
float pad5;
};
layout(std140, binding=3) uniform live
{
st_live l_obj[400];
};
struct st_matrix/
{
mat4 M_proj;
mat4 M_view;
// mat4 M_tr;
};
layout(std140,binding=4) uniform matrix
{
st_matrix m_obj;
};
mat4 M_translate = {vec4(1,0,0,0),
vec4(0,1,0,0),
vec4(0,0,1,0),
vec4(l_obj[i].offset.x, l_obj[i].offset.y, l_obj[i].offset.z,1)
};
mat4 M_scale = {vec4(l_obj[i].scale.x,0,0,0),
vec4(0,l_obj[i].scale.y,0,0),
vec4(0,0,l_obj[i].scale.z,0),
vec4(0,0,0,1)
};
mat4 M_rotate={vec4(cos(l_obj[i].ang),-sin(l_obj[i].ang),0,0),
vec4(sin(l_obj[i].ang),cos(l_obj[i].ang),0,0),
vec4(0,0,1,0),
vec4(0,0,0,1)};
out tex_io
{
vec2 tex_pos;
flat int tex_index;
}tex_out;
void main()
{
mat4 M_comp= M_scale*M_translate*M_rotate;
gl_Position= m_obj.M_proj*m_obj.M_view*M_comp*v_pos[gl_VertexID];
tex_out.tex_pos = t_pos[gl_VertexID];
tex_out.tex_index = i%5;
}