/Resources/shaders/pointLightingPixel.vsh

http://github.com/tartiflop/ojgl · Vertex Shader File · 45 lines · 32 code · 13 blank · 0 comment · 1 complexity · fb1da95f34d75120c005d17c5a3f4e5f MD5 · raw file

  1. #define MAX_LIGHTS 8
  2. struct Material {
  3. vec4 ambientColor;
  4. vec4 diffuseColor;
  5. vec4 specularColor;
  6. float shininess;
  7. };
  8. attribute vec4 a_vertex;
  9. attribute vec3 a_normal;
  10. attribute vec2 a_texCoord;
  11. uniform mat4 u_mvpMatrix;
  12. uniform mat4 u_mvMatrix;
  13. uniform mat3 u_normalMatrix;
  14. uniform vec4 u_sceneAmbientColor;
  15. uniform Material u_material;
  16. uniform bool u_lightingEnabled;
  17. varying vec4 v_ambient;
  18. varying vec2 v_texCoord;
  19. varying vec4 v_ecPosition3;
  20. varying vec3 v_normal;
  21. varying vec3 v_eye;
  22. void main(void) {
  23. v_ecPosition3 = u_mvMatrix * a_vertex;
  24. v_eye = -vec3(normalize(v_ecPosition3));
  25. v_normal = u_normalMatrix * a_normal;
  26. v_normal = normalize(v_normal);
  27. if (u_lightingEnabled) {
  28. v_ambient = u_sceneAmbientColor * u_material.ambientColor;
  29. }
  30. gl_Position = u_mvpMatrix * a_vertex;
  31. v_texCoord = a_texCoord;
  32. }