worldVertex.vs 755 B

1234567891011121314151617181920212223242526272829303132
  1. #version 430
  2. layout (location = 0) in vec3 position;
  3. layout (location = 1) in vec2 tex;
  4. layout (location = 2) in vec3 normal;
  5. uniform mat4 proj;
  6. uniform mat4 view;
  7. uniform mat4 model;
  8. uniform mat4 projViewShadow;
  9. out vec3 varPosition;
  10. out vec2 varTex;
  11. out vec3 varNormal;
  12. out vec4 varShadow;
  13. const vec3 light = vec3(-0.280166, -0.573576, -0.769751);
  14. void main(void) {
  15. // transforming normals must not use the fourth dimension
  16. // should be the inverse transposed matrix
  17. varNormal = (model * vec4(normal, 0.0)).xyz;
  18. varTex = tex;
  19. vec4 worldPos = view * model * vec4(position, 1.0);
  20. varPosition = worldPos.xyz;
  21. gl_Position = proj * worldPos;
  22. varShadow = projViewShadow * vec4(position - light * 0.0, 1.0);
  23. }