LfSpritePass.vert.glsl 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright (C) 2009-2017, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. // LF sprites vert shader
  6. #include "shaders/Common.glsl"
  7. // Per flare information
  8. struct Sprite
  9. {
  10. vec4 posScale; // xy: Position, zw: Scale
  11. vec4 color;
  12. vec4 depthPad3;
  13. };
  14. // The block contains data for all flares
  15. layout(std140, ANKI_UBO_BINDING(0, 0)) uniform _blk
  16. {
  17. Sprite u_sprites[MAX_SPRITES];
  18. };
  19. layout(location = 0) out vec3 out_uv;
  20. layout(location = 1) flat out vec4 out_color;
  21. out gl_PerVertex
  22. {
  23. vec4 gl_Position;
  24. };
  25. void main()
  26. {
  27. const vec2 POSITIONS[4] = vec2[](vec2(-1.0, -1.0), vec2(1.0, -1.0), vec2(-1.0, 1.0), vec2(1.0, 1.0));
  28. vec2 position = POSITIONS[gl_VertexID];
  29. Sprite sprite = u_sprites[gl_InstanceID];
  30. // Write tex coords of the 2D array texture
  31. out_uv = vec3((position * 0.5) + 0.5, sprite.depthPad3.x);
  32. vec4 posScale = sprite.posScale;
  33. ANKI_WRITE_POSITION(vec4(position * posScale.zw + posScale.xy, 0.0, 1.0));
  34. out_color = sprite.color;
  35. }