KlassischeKeplerKriege/data/shader/gameobjects.vert

23 lines
473 B
GLSL
Raw Normal View History

#version 120
2016-09-29 02:24:14 +00:00
attribute vec3 in_vertex;
attribute vec3 in_normal;
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
uniform mat4 model;
2016-09-29 09:38:26 +00:00
uniform vec3 lightPosition;
2016-09-29 02:24:14 +00:00
void main()
{
2016-09-29 09:38:26 +00:00
// TODO: this becomes invalid when projection matrices are used
2016-09-29 06:28:56 +00:00
vec3 p = (model*vec4(in_vertex, 1.0)).xyz;
2016-09-29 09:38:26 +00:00
lightDirection = normalize(lightPosition - p);
2016-09-29 02:24:14 +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
}