added IBR lighting from irradiance maps
[demo] / gl_shaders / morphing.v.glsl
1 #version 450
2
3 uniform mat4 mview;
4 uniform mat4 mmviewproj;
5 uniform mat4 mmod;
6
7 uniform float t;
8 const float half_height = 0.855;
9
10 varying vec3 pos;
11 // varying vec3 normal;
12 // varying vec3 ldir;
13 varying vec2 tex_coord;
14 varying vec3 world_normal;
15
16 // const vec3 lpos = vec3(0.0, 100.0, -10.0);
17
18 /* attributes */
19 layout(location = 1) in vec3 attr_pos;
20 layout(location = 2) in vec3 attr_normal;
21 layout(location = 3) in vec2 attr_tex;
22
23 void main()
24 {
25         vec3 sph_pos = normalize(vec3(attr_pos.x, attr_pos.y - half_height, attr_pos.z));
26
27         vec3 sph_normal = sph_pos;
28         sph_pos.y += half_height;
29
30         vec3 p = mix(attr_pos, sph_pos, t);
31         vec3 n = mix(attr_normal, sph_normal, t);
32
33         gl_Position = mmviewproj * vec4(p, 1.0);
34
35         pos = (mview * vec4(p, 1.0)).xyz;
36         // ldir = (mview * vec4(lpos, 1.0)).xyz;
37
38         // mat3 normal_matrix = mat3(mview);
39         // normal = normal_matrix * n;
40
41         tex_coord = attr_tex;
42         world_normal = (mmod * vec4(attr_normal, 1.0)).xyz;
43 }