You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
686 B

  1. #version 330
  2. // Input vertex attributes
  3. in vec3 vertexPosition;
  4. in vec2 vertexTexCoord;
  5. in vec3 vertexNormal;
  6. // Input uniform values
  7. uniform mat4 mvpMatrix;
  8. // Output vertex attributes (to fragment shader)
  9. out vec2 fragTexCoord;
  10. out vec3 fragNormal;
  11. // NOTE: Add here your custom variables
  12. uniform mat4 modelMatrix;
  13. void main()
  14. {
  15. // Send vertex attributes to fragment shader
  16. fragTexCoord = vertexTexCoord;
  17. // Calculate view vector normal from model
  18. mat3 normalMatrix = transpose(inverse(mat3(modelMatrix)));
  19. fragNormal = normalize(normalMatrix*vertexNormal);
  20. // Calculate final vertex position
  21. gl_Position = mvpMatrix*vec4(vertexPosition, 1.0);
  22. }