/* * Simple textured fragment shader. Modulates texture color with * lambertian shading. * * Alexandri Zavodny, Fall 2010 * for CSE 40166/60166 Computer Graphics, University of Notre Dame */ uniform sampler2D tex; varying vec3 dirToLight, theNormal; void main() { //grab the texture color... vec4 texColor = texture2D(tex, gl_TexCoord[0].st); //perform some simple lambertian shading... float lambertianIntensity = max(dot(normalize(theNormal), normalize(dirToLight)),0.0); //and modulate that with the texture color. et voila! gl_FragColor = vec4(lambertianIntensity*texColor.rgb, texColor.a) + vec4(0.1,0.1,0.1,0.0); }