//////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////// // simple toon vertex shader from www.lighthouse3d.com // normal and lightDir will be sent to the fragment shader varying vec3 normal, lightDir; void main() { // gl_LightSource[0].position - uniform vector provided by GLSL // the light position is already stored in eye space coordinates lightDir = normalize(vec3(gl_LightSource[0].position)); // convert normal to eye space coordinates using gl_NormalMatrix // gl_NormalMatrix is built in uniform matrix provided by GLSL // representing the inverse transpose model-view matrix normal = normalize(gl_NormalMatrix * gl_Normal); // leave the position of the vertices alone gl_Position = ftransform(); // uncomment these lines to see a flattened teapot /* vec4 p; p.xyzw = gl_Vertex.xyzw; // gl_Vertex - attribute provided by GLSL p.y = 0.1 * gl_Vertex.y; // gl_ModelViewProjectionMatrix - uniform matrix provided by GLSL gl_Position = gl_ModelViewProjectionMatrix * p; */ }