KlassischeKeplerKriege/data/shader/gameobjects.vert

24 lines
No EOL
528 B
GLSL

#version 120
attribute vec3 in_vertex;
attribute vec3 in_normal;
varying vec3 vertex;
varying vec3 normal;
varying vec3 lightDirection;
uniform mat4 model;
uniform vec3 lightPosition;
uniform float aspectRatio;
void main()
{
// TODO: this becomes invalid when projection matrices are used
vec3 p = (model*vec4(in_vertex/vec3(aspectRatio, 1.0, 1.0), 1.0)).xyz;
lightDirection = normalize(lightPosition - p);
vertex = p.xyz;
normal = normalize((model*vec4(in_normal.xyz, 0.0)).xyz);
gl_Position = vec4(p, 1.0);
}