Platformer in OpenGL
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
506 B

  1. #version 150
  2. in vec4 fPosition;
  3. in vec4 fColor;
  4. in vec4 fLightPosition;
  5. in vec3 fNormal;
  6. // output
  7. out vec4 color;
  8. void main(void)
  9. {
  10. vec3 o =-normalize(fPosition.xyz);
  11. vec3 n = normalize(fNormal);
  12. vec3 r = reflect(o,n);
  13. vec3 l = normalize(fLightPosition.xyz-fPosition.xyz);
  14. float ambient = 0.1;
  15. float diffus = 0.7*max(0.0,dot(n,l));
  16. float specular = 0.6*pow(max(0.0,-dot(r,l)),4.0);
  17. color = fColor * ( ambient + diffus + specular );
  18. /*color = vec3(1,0,0);*/
  19. }