No Description

gbuffer.vert 893B

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 vec2 inUV;
  6. layout (location = 2) in vec3 inColor;
  7. layout (location = 3) in vec3 inNormal;
  8. layout (binding = 0) uniform UBO
  9. {
  10. mat4 projection;
  11. mat4 model;
  12. mat4 view;
  13. } ubo;
  14. layout (location = 0) out vec3 outNormal;
  15. layout (location = 1) out vec2 outUV;
  16. layout (location = 2) out vec3 outColor;
  17. layout (location = 3) out vec3 outPos;
  18. out gl_PerVertex
  19. {
  20. vec4 gl_Position;
  21. };
  22. void main()
  23. {
  24. gl_Position = ubo.projection * ubo.view * ubo.model * inPos;
  25. outUV = inUV;
  26. // Vertex position in view space
  27. outPos = vec3(ubo.view * ubo.model * inPos);
  28. // Normal in view space
  29. mat3 normalMatrix = transpose(inverse(mat3(ubo.view * ubo.model)));
  30. outNormal = normalMatrix * inNormal;
  31. outColor = inColor;
  32. }