Want more features on Pastebin? Sign Up, it's FREE!
Guest

fragment

By: a guest on Jul 23rd, 2013  |  syntax: None  |  size: 0.63 KB  |  views: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. }
clone this paste RAW Paste Data