// Phong fragment shader varying vec3 oglnormal; // input from vertex shader varying vec3 oglcolor; // input from vertex shader varying vec3 ogllight0; // OpenGL light directions... varying vec3 ogllight1; void main(void) { float diffuse = 0.0; float specular = 0.0; vec3 N = normalize(oglnormal); // calculate diffuse lighting contribution diffuse += max(0.0, dot(N, ogllight0)); // XXX If I do more than one light, I run the card out of resources and // the shader fails to load // diffuse += max(0.0, dot(N, ogllight1)); diffuse = clamp(diffuse, 0.0, 1.0); diffuse *= 0.60; // calculate specular lighting contribution vec3 V = vec3(0.0, 0.0, -1.0); specular += pow(clamp(dot(reflect(ogllight0, N), V), 0.0, 1.0), 10.0); // XXX If I do more than one light, I run the card out of resources and // the shader fails to load // specular += pow(clamp(dot(reflect(ogllight1, N), V), 0.0, 1.0), 10.0); specular = clamp(specular, 0.0, 1.0); specular *= 0.40; gl_FragColor = vec4((oglcolor * vec3(diffuse)) + vec3(specular), 1.0); }