暂无描述

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 vec3 inPos;
  5. layout (location = 1) in vec3 inNormal;
  6. layout (binding = 0) uniform UBO
  7. {
  8. mat4 projection;
  9. mat4 model;
  10. float lodBias;
  11. } ubo;
  12. layout (location = 0) out vec3 outPos;
  13. layout (location = 1) out vec3 outNormal;
  14. layout (location = 2) out float outLodBias;
  15. layout (location = 3) out vec3 outViewVec;
  16. layout (location = 4) out vec3 outLightVec;
  17. layout (location = 5) out mat4 outInvModelView;
  18. out gl_PerVertex
  19. {
  20. vec4 gl_Position;
  21. };
  22. void main()
  23. {
  24. gl_Position = ubo.projection * ubo.model * vec4(inPos.xyz, 1.0);
  25. outPos = vec3(ubo.model * vec4(inPos, 1.0));
  26. outNormal = mat3(ubo.model) * inNormal;
  27. outLodBias = ubo.lodBias;
  28. outInvModelView = inverse(ubo.model);
  29. vec3 lightPos = vec3(0.0f, -5.0f, 5.0f);
  30. outLightVec = lightPos.xyz - outPos.xyz;
  31. outViewVec = -outPos.xyz;
  32. }