LensFlareSprite.ankiprog 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright (C) 2009-2020, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #pragma anki start vert
  6. #include <shaders/Common.glsl>
  7. #include <shaders/glsl_cpp_common/LensFlareSprite.h>
  8. // The block contains data for all flares
  9. layout(std140, set = 0, binding = 0) readonly buffer ssbo00
  10. {
  11. LensFlareSprite u_sprites[];
  12. };
  13. layout(location = 0) out Vec3 out_uv;
  14. layout(location = 1) flat out Vec4 out_color;
  15. out gl_PerVertex
  16. {
  17. Vec4 gl_Position;
  18. };
  19. void main()
  20. {
  21. const Vec2 position = UV_TO_NDC(Vec2(gl_VertexID & 1, gl_VertexID >> 1));
  22. const LensFlareSprite sprite = u_sprites[gl_InstanceID];
  23. // Write tex coords of the 2D array texture
  24. out_uv = Vec3((position * 0.5) + 0.5, sprite.m_depthPad3.x);
  25. const Vec4 posScale = sprite.m_posScale;
  26. gl_Position = Vec4(position * posScale.zw + posScale.xy, 0.0, 1.0);
  27. out_color = sprite.m_color;
  28. }
  29. #pragma anki end
  30. #pragma anki start frag
  31. #include <shaders/Common.glsl>
  32. layout(set = 0, binding = 1) uniform sampler u_trilinearRepeatSampler;
  33. layout(set = 0, binding = 2) uniform texture2DArray u_tex;
  34. layout(location = 0) in Vec3 in_uv;
  35. layout(location = 1) flat in Vec4 in_color;
  36. layout(location = 0) out Vec4 out_color;
  37. void main()
  38. {
  39. const Vec4 col = texture(u_tex, u_trilinearRepeatSampler, in_uv);
  40. out_color = col * in_color;
  41. }
  42. #pragma anki end