2016-09-29 00:50:51 +00:00
|
|
|
#version 120
|
2016-09-29 02:24:14 +00:00
|
|
|
|
|
|
|
attribute vec3 in_vertex;
|
|
|
|
attribute vec3 in_normal;
|
|
|
|
|
2016-09-29 00:50:51 +00:00
|
|
|
varying vec3 vertex;
|
2016-09-29 02:24:14 +00:00
|
|
|
varying vec3 normal;
|
2016-09-29 09:38:26 +00:00
|
|
|
varying vec3 lightDirection;
|
2016-09-29 02:24:14 +00:00
|
|
|
|
2016-09-29 00:50:51 +00:00
|
|
|
uniform mat4 model;
|
2016-09-29 09:38:26 +00:00
|
|
|
uniform vec3 lightPosition;
|
2016-10-02 09:00:03 +00:00
|
|
|
uniform float aspectRatio;
|
2016-09-29 02:24:14 +00:00
|
|
|
|
2016-09-29 00:50:51 +00:00
|
|
|
void main()
|
|
|
|
{
|
2016-09-29 09:38:26 +00:00
|
|
|
// TODO: this becomes invalid when projection matrices are used
|
2016-10-04 17:12:04 +00:00
|
|
|
vec3 p = (model*vec4(in_vertex/vec3(aspectRatio, 1.0, 1.0), 1.0)).xyz;
|
2016-09-29 09:38:26 +00:00
|
|
|
lightDirection = normalize(lightPosition - p);
|
2016-09-29 02:24:14 +00:00
|
|
|
|
2016-09-29 00:50:51 +00:00
|
|
|
vertex = p.xyz;
|
2016-09-29 06:28:56 +00:00
|
|
|
normal = normalize((model*vec4(in_normal.xyz, 0.0)).xyz);
|
2016-09-29 02:24:14 +00:00
|
|
|
|
|
|
|
gl_Position = vec4(p, 1.0);
|
2016-09-29 10:28:35 +00:00
|
|
|
}
|