Advertisement
Guest User

Untitled

a guest
Apr 10th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. #version 330
  2.  
  3. // Uniforms
  4. uniform mat4 matrixProjection;
  5. uniform mat4 matrixModelView;
  6. uniform mat4 matrixView;
  7.  
  8. uniform vec3 materialAmbient;
  9.  
  10. layout (location = 0) in vec3 aVertex;
  11. layout (location = 2) in vec3 aNormal;
  12. layout (location = 3) in vec2 aTexCoord;
  13.  
  14. out vec4 color;
  15. out vec4 position;
  16. out vec3 normal;
  17. out vec2 texCoord0;
  18.  
  19.  
  20. // ambient light declaration
  21. struct AMBIENT
  22. {
  23. int on;
  24. vec3 color;
  25. };
  26. uniform AMBIENT lightAmbient;
  27.  
  28.  
  29.  
  30. // ambient light function
  31. vec4 AmbientLight(AMBIENT light)
  32. {
  33. return vec4(materialAmbient * light.color, 1);
  34. }
  35.  
  36.  
  37. void main(void)
  38. {
  39. // calculate position
  40. position = matrixModelView * vec4(aVertex, 1.0);
  41. gl_Position = matrixProjection * position;
  42.  
  43. // calculate normal
  44. normal = normalize(mat3(matrixModelView) * aNormal);
  45.  
  46. // calculate texture coordinate
  47. texCoord0 = aTexCoord;
  48.  
  49.  
  50. color = vec4(0.0, 0.0, 0.0, 1.0);
  51.  
  52. if (lightAmbient.on == 1) color += AmbientLight(lightAmbient);
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement