phong.vs 669 B

1234567891011121314151617181920212223242526272829
  1. #version 330
  2. // Vertex input data
  3. in vec3 vertexPosition;
  4. in vec2 vertexTexCoord;
  5. in vec3 vertexNormal;
  6. // Projection and model data
  7. uniform mat4 mvpMatrix;
  8. uniform mat4 modelMatrix;
  9. //uniform mat4 viewMatrix; // Not used
  10. // Attributes to fragment shader
  11. out vec2 fragTexCoord;
  12. out vec3 fragNormal;
  13. void main()
  14. {
  15. // Send texture coord 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. }