1 /* 2 Copyright (c) 2008 Seneca College 3 Licenced under the MIT License (http://www.c3dl.org/index.php/mit-license/) 4 */ 5 6 c3dl.cartoon_vs = 7 8 "attribute vec3 Vertex;" + 9 "attribute vec3 Normal;" + 10 "attribute vec3 Texture;" + 11 12 "varying vec3 norm;" + 13 "varying vec3 pos;" + 14 15 // for every model we multiply the projection, view and model matrices 16 // once to prevent having to do it for every vertex, however we still need 17 // the model and view matrices to calculate lighting. 18 "uniform mat4 modelViewMatrix;" + 19 20 // we can calculate this once per model to speed up processing done on the js side. 21 "uniform mat4 modelViewProjMatrix;" + 22 23 // matrix to transform the vertex normals 24 "uniform mat4 normalMatrix;" + 25 26 /* 27 28 */ 29 "void main(void)" + 30 "{" + 31 32 // create a normal matrix 3x3 out of 4x4 33 " mat3 normalMatrix3x3 = mat3(normalMatrix[0][0],normalMatrix[0][1],normalMatrix[0][2],normalMatrix[1][0],normalMatrix[1][1],normalMatrix[1][2],normalMatrix[2][0],normalMatrix[2][1],normalMatrix[2][2]);" + 34 " norm = normalize(normalMatrix3x3 * Normal);" + 35 36 " gl_Position = modelViewProjMatrix * vec4(Vertex, 1.0);" + 37 " pos = vec3( modelViewMatrix * vec4(Vertex,1.0));" + 38 39 " gl_TexCoord[0] = vec4(Texture,1.0);" + 40 "}"; 41