No Description

multiview.vert 857B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #version 450
  2. #extension GL_EXT_multiview : enable
  3. layout (location = 0) in vec3 inPos;
  4. layout (location = 1) in vec3 inNormal;
  5. layout (location = 2) in vec3 inColor;
  6. layout (location = 0) out vec3 outNormal;
  7. layout (location = 1) out vec3 outColor;
  8. layout (location = 2) out vec3 outViewVec;
  9. layout (location = 3) out vec3 outLightVec;
  10. layout (binding = 0) uniform UBO
  11. {
  12. mat4 projection[2];
  13. mat4 modelview[2];
  14. vec4 lightPos;
  15. } ubo;
  16. out gl_PerVertex
  17. {
  18. vec4 gl_Position;
  19. };
  20. void main()
  21. {
  22. outColor = inColor;
  23. outNormal = mat3(ubo.modelview[gl_ViewIndex]) * inNormal;
  24. vec4 pos = vec4(inPos.xyz, 1.0);
  25. vec4 worldPos = ubo.modelview[gl_ViewIndex] * pos;
  26. vec3 lPos = vec3(ubo.modelview[gl_ViewIndex] * ubo.lightPos);
  27. outLightVec = lPos - worldPos.xyz;
  28. outViewVec = -worldPos.xyz;
  29. gl_Position = ubo.projection[gl_ViewIndex] * worldPos;
  30. }