aboutsummaryrefslogtreecommitdiff
path: root/data/shaders/light-phong.vert
blob: 8a95ca7bb1923f8963262bcae246d0b8e99d4c35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
attribute vec3 position;
attribute vec3 normal;

uniform mat4 ModelViewProjectionMatrix;
uniform mat4 NormalMatrix;
uniform mat4 ModelViewMatrix;

varying vec3 vertex_normal;
varying vec4 vertex_position;

void main(void)
{
    vec4 current_position = vec4(position, 1.0);

    // Transform the normal to eye coordinates
    vertex_normal = normalize(vec3(NormalMatrix * vec4(normal, 1.0)));

    // Transform the current position to eye coordinates
    vertex_position = ModelViewMatrix * current_position;

    // Transform the current position to clip coordinates
    gl_Position = ModelViewProjectionMatrix * current_position;
}