KlassischeKeplerKriege/data/shader/gameobjects.vert

27 lines
602 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;
uniform mat4 view;
2016-09-29 09:38:26 +00:00
uniform vec3 lightPosition;
uniform float aspectRatio;
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
vec3 asp = vec3(aspectRatio, 1.0, 1.0);
//vec3 asp = vec3(1.0, 1.0, 1.0);
vec3 p = (view*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
}