vec3 L = normalize(lightPos - vertPos);
void main() { vec3 N = normalize(normalInterp); vec3 L = normalize(lightPos - vertPos); // Lambert's cosine law float lambertian = max(dot(N, L), 0.0);
if(lambertian > 0.0) { vec3 R = reflect(-L, N); // Reflected light vector vec3 V = normalize(-vertPos); // Vector to viewer // Compute the specular term float specAngle = max(dot(R, V), 0.0); specular = pow(specAngle, shininessVal);