summaryrefslogtreecommitdiff
path: root/data/shaders/phong-vert.glsl
diff options
context:
space:
mode:
Diffstat (limited to 'data/shaders/phong-vert.glsl')
-rw-r--r--data/shaders/phong-vert.glsl34
1 files changed, 34 insertions, 0 deletions
diff --git a/data/shaders/phong-vert.glsl b/data/shaders/phong-vert.glsl
new file mode 100644
index 0000000..51461fa
--- /dev/null
+++ b/data/shaders/phong-vert.glsl
@@ -0,0 +1,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;
+}