Нет описания

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 view;
  12. mat4 model;
  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 outViewVec;
  18. layout (location = 4) out vec3 outLightVec;
  19. out gl_PerVertex
  20. {
  21. vec4 gl_Position;
  22. };
  23. void main()
  24. {
  25. outNormal = inNormal;
  26. outColor = inColor;
  27. outUV = inUV;
  28. gl_Position = ubo.projection * ubo.view * ubo.model * inPos;
  29. vec3 lightPos = vec3(-5.0, -5.0, 0.0);
  30. vec4 pos = ubo.view * ubo.model * inPos;
  31. outNormal = mat3(ubo.view * ubo.model) * inNormal;
  32. outLightVec = lightPos - pos.xyz;
  33. outViewVec = -pos.xyz;
  34. }