summaryrefslogtreecommitdiffhomepage
path: root/shaders/gl330/phong.vs
diff options
context:
space:
mode:
authorRay <[email protected]>2016-02-20 01:09:47 +0100
committerRay <[email protected]>2016-02-20 01:09:47 +0100
commit4b6e6d4dd45fc3a47b82af7eeb60871140a7eccf (patch)
treed9ee679c3b0bc5d4a20b31930994deb0e4c37948 /shaders/gl330/phong.vs
parentf582ab06add085594f2579ee6e7d625212abd204 (diff)
parent954ced21a42eb489ad382b4c00406a28778fee41 (diff)
downloadraylib-4b6e6d4dd45fc3a47b82af7eeb60871140a7eccf.tar.gz
raylib-4b6e6d4dd45fc3a47b82af7eeb60871140a7eccf.zip
Merge pull request #83 from raysan5/develop
Develop branch integration
Diffstat (limited to 'shaders/gl330/phong.vs')
-rw-r--r--shaders/gl330/phong.vs27
1 files changed, 27 insertions, 0 deletions
diff --git a/shaders/gl330/phong.vs b/shaders/gl330/phong.vs
new file mode 100644
index 00000000..ee6d34bf
--- /dev/null
+++ b/shaders/gl330/phong.vs
@@ -0,0 +1,27 @@
+#version 330
+
+// Vertex input data
+in vec3 vertexPosition;
+in vec2 vertexTexCoord;
+in vec3 vertexNormal;
+
+// Projection and model data
+uniform mat4 mvpMatrix;
+uniform mat4 modelMatrix;
+
+// Attributes to fragment shader
+out vec2 fragTexCoord;
+out vec3 fragNormal;
+
+void main()
+{
+ // Send texture coord to fragment shader
+ fragTexCoord = vertexTexCoord;
+
+ // Calculate view vector normal from model
+ mat3 normalMatrix = transpose(inverse(mat3(modelMatrix)));
+ fragNormal = normalize(normalMatrix*vertexNormal);
+
+ // Calculate final vertex position
+ gl_Position = mvpMatrix*vec4(vertexPosition, 1.0);
+} \ No newline at end of file