// Lighthouse 3D Tutorial toon shader
// 	http://www.lighthouse3d.com/opengl/glsl/index.php?toon2
// By way of:
//  http://www.pygame.org/wiki/GLSLExample
#version 330 core

// Where the light is, in eye coordinates.  The fixed-function pipeline kept
// this in gl_LightSource[0].position; a core profile has the application say.
uniform vec3 light_location;

in vec3 normal;
out vec4 fragColor;

void main() {
	float intensity;
	vec3 n = normalize(normal);
	vec3 l = normalize(light_location);

	// quantize to 5 steps (0, .25, .5, .75 and 1)
	intensity = (floor(dot(l, n) * 4.0) + 1.0)/4.0;
	fragColor = vec4(intensity*1.0, intensity*0.5, intensity*0.5,
		intensity*1.0);
}
