worldVertex.vs 858 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #version 430
  2. layout (location = 0) in vec3 position;
  3. layout (location = 1) in vec4 color;
  4. layout (location = 2) in vec2 textureCoord;
  5. layout (location = 3) in vec3 normal;
  6. uniform mat4 projMatrix;
  7. uniform mat4 viewMatrix;
  8. uniform mat4 modelMatrix;
  9. out vec3 varPosition;
  10. out vec2 varTextureCoord;
  11. out vec4 varColor;
  12. out vec3 varNormal;
  13. void main(void)
  14. {
  15. // transforming normals must not use the fourth dimension
  16. varNormal = (viewMatrix * modelMatrix * vec4(normal, 0.0)).xyz;
  17. varTextureCoord = textureCoord;
  18. varColor = vec4(color.xyz, 1);
  19. if(abs(normal.x) == 1)
  20. {
  21. varColor = varColor * 0.8;
  22. }
  23. if(abs(normal.z) == 1)
  24. {
  25. varColor = varColor * 0.9;
  26. }
  27. vec4 viewPos = viewMatrix * modelMatrix * vec4(position, 1.0);
  28. varPosition = viewPos.xyz;
  29. gl_Position = projMatrix * viewPos;
  30. }