No Description

lights.vert 1000B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 (location = 3) in vec3 inColor;
  7. #define lightCount 6
  8. layout (binding = 0) uniform UBO
  9. {
  10. mat4 projection;
  11. mat4 model;
  12. vec4 lightColor[lightCount];
  13. } ubo;
  14. layout(push_constant) uniform PushConsts {
  15. vec4 lightPos[lightCount];
  16. } pushConsts;
  17. layout (location = 0) out vec3 outNormal;
  18. layout (location = 2) out vec3 outColor;
  19. layout (location = 3) out vec4 outLightVec[lightCount];
  20. out gl_PerVertex
  21. {
  22. vec4 gl_Position;
  23. };
  24. void main()
  25. {
  26. outNormal = inNormal;
  27. outColor = inColor;
  28. gl_Position = ubo.projection * ubo.model * vec4(inPos.xyz, 1.0);
  29. for (int i = 0; i < lightCount; ++i)
  30. {
  31. vec4 worldPos = ubo.model * vec4(inPos.xyz, 1.0);
  32. outLightVec[i].xyz = pushConsts.lightPos[i].xyz - inPos.xyz;
  33. // Store light radius in w
  34. outLightVec[i].w = pushConsts.lightPos[i].w;
  35. }
  36. }