summaryrefslogtreecommitdiff
path: root/data/shaders/phong-vert.glsl
blob: 51461fa9f0c69df512f9cc0134720a645c027e3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// -*- mode: c -*-

#ifdef GLSL330
layout (location = 0) in vec3 position;
layout (location = 1) in vec2 texcoord;
layout (location = 2) in vec3 normal;
#elif defined(GLSL130)
in vec3 position;
in vec2 texcoord;
in vec3 normal;
#elif defined(GLSL120)
attribute vec3 position;
attribute vec2 texcoord;
attribute vec3 normal;
#endif

#ifdef GLSL120
varying vec3 fragNorm;
varying vec2 fragTex;
#else
out vec3 fragNorm;
out vec2 fragTex;
#endif

uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;

void main() {
  gl_Position = projection * view * model * vec4(position, 1.0);
  // TODO: Calculate normal matrix on CPU
  fragNorm = normalize(model * vec4(normal, 1.0)).xyz;
  fragTex = texcoord;
}