Keine Beschreibung

12345678910111213141516171819202122232425262728293031323334
  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 inNormal;
  6. layout (location = 3) in vec3 inColor;
  7. layout (binding = 0) uniform UBO
  8. {
  9. mat4 projection;
  10. mat4 model;
  11. mat4 normal;
  12. mat4 view;
  13. int texIndex;
  14. } ubo;
  15. layout (location = 0) out vec3 outColor;
  16. layout (location = 1) out vec3 outEyePos;
  17. layout (location = 2) out vec3 outNormal;
  18. layout (location = 3) out flat int outTexIndex;
  19. void main()
  20. {
  21. outColor = inColor;
  22. mat4 modelView = ubo.view * ubo.model;
  23. outEyePos = normalize( vec3( modelView * inPos ) );
  24. outTexIndex = ubo.texIndex;
  25. outNormal = normalize( mat3(ubo.normal) * inNormal );
  26. vec3 r = reflect( outEyePos, outNormal );
  27. float m = 2.0 * sqrt( pow(r.x, 2.0) + pow(r.y, 2.0) + pow(r.z + 1.0, 2.0));
  28. gl_Position = ubo.projection * modelView * inPos;
  29. }