Changed the OpenGL part and the GLSL shaders to use UBO and
[demo] / vk_shaders / morphing.v.glsl
1 #version 450
2
3 layout(std140, binding = 0) uniform matrix_state {
4         mat4 mview;
5         mat4 mmviewproj;
6         mat4 mmod;
7         float t;
8 } m;
9
10 const float half_height = 0.855;
11
12 layout(location = 0) out vec3 pos;
13 layout(location = 1) out vec2 tex_coord;
14 layout(location = 2) out vec3 world_normal;
15
16 /* attributes */
17 layout(location = 1) in vec3 attr_pos;
18 layout(location = 2) in vec3 attr_normal;
19 layout(location = 3) in vec2 attr_tex;
20
21 void main()
22 {
23         vec3 sph_pos = normalize(vec3(attr_pos.x, attr_pos.y - half_height, attr_pos.z));
24
25         vec3 sph_normal = sph_pos;
26         sph_pos.y += half_height;
27
28         vec3 p = mix(attr_pos, sph_pos, m.t);
29         vec3 n = mix(attr_normal, sph_normal, m.t);
30
31         gl_Position = m.mmviewproj * vec4(p, 1.0);
32
33         pos = (m.mview * vec4(p, 1.0)).xyz;
34         // ldir = (mview * vec4(lpos, 1.0)).xyz;
35
36         // mat3 normal_matrix = mat3(mview);
37         // normal = normal_matrix * n;
38
39         tex_coord = attr_tex;
40         world_normal = (m.mmod * vec4(attr_normal, 1.0)).xyz;
41 }