worldVertex.vs 806 B

1234567891011121314151617181920212223242526272829303132333435
  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 projShadow;
  9. uniform mat4 viewShadow;
  10. uniform mat4 projViewShadow;
  11. out vec3 varPosition;
  12. out vec2 varTex;
  13. out vec3 varNormal;
  14. out vec4 varShadow;
  15. const vec3 light = vec3(-0.280166, -0.573576, -0.769751);
  16. void main(void)
  17. {
  18. // transforming normals must not use the fourth dimension
  19. // should be the inverse transposed matrix
  20. varNormal = (model * vec4(normal, 0.0)).xyz;
  21. varTex = tex;
  22. vec4 worldPos = view * model * vec4(position, 1.0);
  23. varPosition = worldPos.xyz;
  24. gl_Position = proj * worldPos;
  25. varShadow = projViewShadow * vec4(position - light * 0.05, 1.0);
  26. }