worldVertex.vs 936 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. uniform bool useTexture;
  10. uniform bool useColor;
  11. uniform bool useMixColor;
  12. uniform vec4 mixColor;
  13. uniform bool useNormals;
  14. out vec3 varPosition;
  15. out vec2 varTextureCoord;
  16. out vec4 varColor;
  17. out vec3 varNormal;
  18. void main(void)
  19. {
  20. varNormal = normal;
  21. varTextureCoord = textureCoord;
  22. varColor = vec4(color.xyz, 1);
  23. if(useNormals)
  24. {
  25. if(abs(normal.x) == 1)
  26. {
  27. varColor = varColor * 0.8;
  28. }
  29. if(abs(normal.z) == 1)
  30. {
  31. varColor = varColor * 0.9;
  32. }
  33. }
  34. vec4 worldPos = modelMatrix * vec4(position, 1.0);
  35. varPosition = worldPos.xyz;
  36. gl_Position = projMatrix * viewMatrix * worldPos;
  37. }