Advertisement
Guest User

Untitled

a guest
Dec 13th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. #if (numPointLights > 0) && defined(normalFlag)
  2. for (int i = 0; i < numPointLights; i++) {
  3. vec3 lightDir = u_pointLights[i].position - pos.xyz;
  4. float dist2 = dot(lightDir, lightDir);
  5. lightDir *= inversesqrt(dist2);
  6. float NdotL = clamp(dot(normal, lightDir), 0.0, 1.0);
  7. vec3 value = u_pointLights[i].color * (NdotL / (1.0 + dist2));
  8. v_lightDiffuse += value;
  9. #ifdef specularFlag
  10. float halfDotView = max(0.0, dot(normal, normalize(lightDir + viewVec)));
  11. v_lightSpecular += value * pow(halfDotView, u_shininess);
  12. #endif // specularFlag
  13. }
  14. #endif // numPointLights
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement