No Description

scene.vert 944B

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