No Description

mrt.vert 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #version 450
  2. #extension GL_ARB_separate_shader_objects : enable
  3. #extension GL_ARB_shading_language_420pack : enable
  4. layout (location = 0) in vec4 inPos;
  5. layout (location = 1) in vec2 inUV;
  6. layout (location = 2) in vec3 inColor;
  7. layout (location = 3) in vec3 inNormal;
  8. layout (location = 4) in vec3 inTangent;
  9. layout (binding = 0) uniform UBO
  10. {
  11. mat4 projection;
  12. mat4 model;
  13. mat4 view;
  14. vec4 instancePos[3];
  15. } ubo;
  16. layout (location = 0) out vec3 outNormal;
  17. layout (location = 1) out vec2 outUV;
  18. layout (location = 2) out vec3 outColor;
  19. layout (location = 3) out vec3 outWorldPos;
  20. layout (location = 4) out vec3 outTangent;
  21. void main()
  22. {
  23. vec4 tmpPos = inPos + ubo.instancePos[gl_InstanceIndex];
  24. gl_Position = ubo.projection * ubo.view * ubo.model * tmpPos;
  25. outUV = inUV;
  26. outUV.t = 1.0 - outUV.t;
  27. // Vertex position in world space
  28. outWorldPos = vec3(ubo.model * tmpPos);
  29. // Normal in world space
  30. mat3 mNormal = transpose(inverse(mat3(ubo.model)));
  31. outNormal = mNormal * normalize(inNormal);
  32. outTangent = mNormal * normalize(inTangent);
  33. // Currently just vertex color
  34. outColor = inColor;
  35. }