No Description

mesh.vert 968B

12345678910111213141516171819202122232425262728293031323334353637
  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 = 2) in vec2 inTexCoord;
  7. layout (location = 3) in vec3 inColor;
  8. layout (binding = 0) uniform UBO
  9. {
  10. mat4 projection;
  11. mat4 model;
  12. mat4 normal;
  13. mat4 view;
  14. vec3 lightpos;
  15. } ubo;
  16. layout (location = 0) out vec2 outUV;
  17. layout (location = 1) out vec3 outNormal;
  18. layout (location = 2) out vec3 outColor;
  19. layout (location = 3) out vec3 outEyePos;
  20. layout (location = 4) out vec3 outLightVec;
  21. void main()
  22. {
  23. outUV = inTexCoord.st;
  24. outNormal = normalize(mat3(ubo.normal) * inNormal);
  25. outColor = inColor;
  26. mat4 modelView = ubo.view * ubo.model;
  27. vec4 pos = modelView * inPos;
  28. gl_Position = ubo.projection * pos;
  29. outEyePos = vec3(modelView * pos);
  30. vec4 lightPos = vec4(ubo.lightpos, 1.0) * modelView;
  31. outLightVec = normalize(lightPos.xyz - outEyePos);
  32. }