No Description

particle.vert 851B

1234567891011121314151617181920212223242526272829303132333435
  1. #version 450
  2. #extension GL_ARB_separate_shader_objects : enable
  3. #extension GL_ARB_shading_language_420pack : enable
  4. layout (location = 0) in vec4 inPos;
  5. layout (location = 1) in vec4 inVel;
  6. layout (location = 0) out float outGradientPos;
  7. layout (binding = 2) uniform UBO
  8. {
  9. mat4 projection;
  10. mat4 modelview;
  11. vec2 screendim;
  12. } ubo;
  13. out gl_PerVertex
  14. {
  15. vec4 gl_Position;
  16. float gl_PointSize;
  17. };
  18. void main ()
  19. {
  20. const float spriteSize = 0.005 * inPos.w; // Point size influenced by mass (stored in inPos.w);
  21. vec4 eyePos = ubo.modelview * vec4(inPos.x, inPos.y, inPos.z, 1.0);
  22. vec4 projectedCorner = ubo.projection * vec4(0.5 * spriteSize, 0.5 * spriteSize, eyePos.z, eyePos.w);
  23. gl_PointSize = clamp(ubo.screendim.x * projectedCorner.x / projectedCorner.w, 1.0, 128.0);
  24. gl_Position = ubo.projection * eyePos;
  25. outGradientPos = inVel.w;
  26. }