Advertisement
Guest User

fragment

a guest
Jul 23rd, 2013
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #version 150
  2.  
  3. uniform vec4 diffuse;
  4. uniform vec4 ambient;
  5. uniform vec4 specular;
  6. uniform float shininess;
  7.  
  8. uniform vec3 lightPos;
  9.  
  10. in vec4 eye;
  11. in vec3 normal;
  12.  
  13. in vec4 passColor;
  14. in vec2 passTexCoord;
  15.  
  16. out vec4 outColor;
  17.  
  18. void main()
  19. {
  20. vec4 spec = vec4(0.0);
  21.  
  22. vec3 n = normalize(normal);
  23. vec3 e = normalize(vec3(eye));
  24.  
  25. float intensity = max(dot(n, lightPos), 0.0);
  26.  
  27. if(intensity > 0.0)
  28. {
  29. vec3 h = normalize(lightPos + e);
  30. float intSpec = max(dot(h,n), 0.0);
  31. spec = specular * pow(intSpec, shininess);
  32. }
  33.  
  34. outColor = max(intensity * diffuse + spec, ambient);
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement