/* * Vertex shader for "angle-of-incidence" based shading: computes the usual * lighting / normal varyings, and also computes the normal in device * coordinates (see notes below; technically in clip space here). * * Alexandri Zavodny, Fall 2010 * for CSE 40166/60166 Computer Graphics, University of Notre Dame */ varying vec4 theColor; varying vec3 theNormal; varying vec4 normalInDeviceCoords; varying vec3 dirToLight; void main() { theColor = gl_Color; vec4 transformedVertex = gl_ModelViewMatrix * gl_Vertex; dirToLight = normalize( vec3(gl_LightSource[0].position - transformedVertex) ); theNormal = normalize(gl_NormalMatrix * gl_Normal); //ok, so TECHNICALLY the normal is in clip space here, but it'll be in //normalized device coordinates by the time it reaches the fragment processor. normalInDeviceCoords = normalize(gl_ProjectionMatrix * vec4(theNormal, 0.0)); gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; }