No Description

mrt.vert 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. out gl_PerVertex
  22. {
  23. vec4 gl_Position;
  24. };
  25. void main()
  26. {
  27. vec4 tmpPos = inPos + ubo.instancePos[gl_InstanceIndex];
  28. gl_Position = ubo.projection * ubo.view * ubo.model * tmpPos;
  29. outUV = inUV;
  30. outUV.t = 1.0 - outUV.t;
  31. // Vertex position in world space
  32. outWorldPos = vec3(ubo.model * tmpPos);
  33. // GL to Vulkan coord space
  34. outWorldPos.y = -outWorldPos.y;
  35. // Normal in world space
  36. mat3 mNormal = transpose(inverse(mat3(ubo.model)));
  37. outNormal = mNormal * normalize(inNormal);
  38. outTangent = mNormal * normalize(inTangent);
  39. // Currently just vertex color
  40. outColor = inColor;
  41. }