Без опису

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #version 450
  2. #extension GL_ARB_separate_shader_objects : enable
  3. #extension GL_ARB_shading_language_420pack : enable
  4. // Vertex attributes
  5. layout (location = 0) in vec4 inPos;
  6. layout (location = 1) in vec3 inNormal;
  7. layout (location = 2) in vec3 inColor;
  8. // Instanced attributes
  9. layout (location = 4) in vec3 instancePos;
  10. layout (location = 5) in float instanceScale;
  11. layout (binding = 0) uniform UBO
  12. {
  13. mat4 projection;
  14. mat4 modelview;
  15. } ubo;
  16. layout (location = 0) out vec3 outNormal;
  17. layout (location = 1) out vec3 outColor;
  18. layout (location = 2) out vec3 outViewVec;
  19. layout (location = 3) out vec3 outLightVec;
  20. out gl_PerVertex
  21. {
  22. vec4 gl_Position;
  23. };
  24. void main()
  25. {
  26. outColor = inColor;
  27. outNormal = inNormal;
  28. vec4 pos = vec4((inPos.xyz * instanceScale) + instancePos, 1.0);
  29. gl_Position = ubo.projection * ubo.modelview * pos;
  30. vec4 wPos = ubo.modelview * vec4(pos.xyz, 1.0);
  31. vec4 lPos = vec4(0.0, 10.0, 50.0, 1.0);
  32. outLightVec = lPos.xyz - pos.xyz;
  33. outViewVec = -pos.xyz;
  34. }