No Description

gbuffer.vert 934B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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 vec3 inColor;
  6. layout (location = 2) in vec3 inNormal;
  7. layout (binding = 0) uniform UBO
  8. {
  9. mat4 projection;
  10. mat4 model;
  11. mat4 view;
  12. } ubo;
  13. layout (location = 0) out vec3 outNormal;
  14. layout (location = 1) out vec3 outColor;
  15. layout (location = 2) out vec3 outWorldPos;
  16. layout (location = 3) out vec3 outTangent;
  17. out gl_PerVertex
  18. {
  19. vec4 gl_Position;
  20. };
  21. void main()
  22. {
  23. gl_Position = ubo.projection * ubo.view * ubo.model * inPos;
  24. // Vertex position in world space
  25. outWorldPos = vec3(ubo.model * inPos);
  26. // GL to Vulkan coord space
  27. outWorldPos.y = -outWorldPos.y;
  28. // Normal in world space
  29. mat3 mNormal = transpose(inverse(mat3(ubo.model)));
  30. outNormal = mNormal * normalize(inNormal);
  31. // Currently just vertex color
  32. outColor = inColor;
  33. }