worldVertex.vs 584 B

1234567891011121314151617181920212223242526
  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. out vec3 varPosition;
  9. out vec2 varTex;
  10. out vec3 varNormal;
  11. void main(void)
  12. {
  13. // transforming normals must not use the fourth dimension
  14. // should be the inverse transposed matrix
  15. varNormal = (view * model * vec4(normal, 0.0)).xyz;
  16. varTex = tex;
  17. vec4 worldPos = view * model * vec4(position, 1.0);
  18. varPosition = worldPos.xyz;
  19. gl_Position = proj * worldPos;
  20. }