2
0

BasicMesh.vert 1002 B

123456789101112131415161718192021222324252627282930313233
  1. // ----------------------------------------------------------------
  2. // From Game Programming in C++ by Sanjay Madhav
  3. // Copyright (C) 2017 Sanjay Madhav. All rights reserved.
  4. //
  5. // Released under the BSD License
  6. // See LICENSE in root directory for full details.
  7. // ----------------------------------------------------------------
  8. // Request GLSL 3.3
  9. #version 330
  10. // Uniforms for world transform and view-proj
  11. uniform mat4 uWorldTransform;
  12. uniform mat4 uViewProj;
  13. // Attribute 0 is position, 1 is normal, 2 is tex coords.
  14. layout(location = 0) in vec3 inPosition;
  15. layout(location = 1) in vec3 inNormal;
  16. layout(location = 2) in vec2 inTexCoord;
  17. // Any vertex outputs (other than position)
  18. out vec2 fragTexCoord;
  19. void main()
  20. {
  21. // Convert position to homogeneous coordinates
  22. vec4 pos = vec4(inPosition, 1.0);
  23. // Transform to position world space, then clip space
  24. gl_Position = pos * uWorldTransform * uViewProj;
  25. // Pass along the texture coordinate to frag shader
  26. fragTexCoord = inTexCoord;
  27. }