simple_shader.vert 809 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #version 450
  2. layout (location = 0) in vec3 position;
  3. layout (location = 1) in vec2 texcoord;
  4. layout (location = 2) in vec3 normal;
  5. layout (location = 0) out vec3 fragPosWorld;
  6. layout (location = 1) out vec2 fragTexcoord;
  7. layout (location = 2) out vec3 fragNormalWorld;
  8. layout (set = 0, binding = 0) uniform GlobalUBO
  9. {
  10. mat4 viewProjection;
  11. // GLOBAL LIGHT
  12. vec4 globalLightDirection;
  13. vec4 ambientLightColor;
  14. // POINT LIGHT
  15. vec4 lightPosition;
  16. vec4 lightColor;
  17. } ubo;
  18. layout (push_constant) uniform Push
  19. {
  20. mat4 worldMatrix;
  21. mat4 normalMatrix;
  22. } push;
  23. void main()
  24. {
  25. vec4 worldPos = push.worldMatrix * vec4(position, 1.0f);
  26. gl_Position = ubo.viewProjection * worldPos;
  27. fragPosWorld = worldPos.xyz;
  28. fragNormalWorld = normalize(mat3(push.normalMatrix) * normal);
  29. fragTexcoord = texcoord;
  30. }