worldVertex.vs 813 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. layout (location = 3) in vec3 tangent;
  6. uniform mat4 proj;
  7. uniform mat4 view;
  8. uniform mat4 model;
  9. uniform mat4 projViewShadow;
  10. out vec3 varPosition;
  11. out vec2 varTex;
  12. out vec3 varNormal;
  13. out vec4 varShadow;
  14. out vec3 varTangent;
  15. void main(void) {
  16. // transforming normals must not use the fourth dimension
  17. // should be the inverse transposed matrix
  18. varNormal = (model * vec4(normal, 0.0)).xyz;
  19. varTangent = (model * vec4(tangent, 0.0)).xyz;
  20. varTex = tex;
  21. vec4 modelPos = model * vec4(position, 1.0);
  22. vec4 worldPos = view * modelPos;
  23. varPosition = worldPos.xyz;
  24. gl_Position = proj * worldPos;
  25. varShadow = projViewShadow * modelPos;
  26. }