/* * Simple vertex shader to animate the position of grass / foliage * based on its location in the X-Z plane as well as a factor * of time. Passes texture coordinates and lighting information along. * * Alexandri Zavodny, Fall 2010 * for CSE 40166/60166 Computer Graphics, University of Notre Dame */ uniform float time; varying vec3 dirToLight, theNormal; void main() { theNormal = normalize(gl_NormalMatrix * gl_Normal); dirToLight = normalize(vec3(gl_LightSource[0].position - gl_ModelViewMatrix * gl_Vertex)); gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; vec4 newVertex = gl_Vertex + vec4(sin(time+gl_Vertex.x)*gl_Vertex.y*0.5, 0, 0, 0.0); gl_Position = gl_ModelViewProjectionMatrix * newVertex; }