FsCommonVert.glsl 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. #ifndef ANKI_SHADERS_FS_COMMON_VERT_GLSL
  6. #define ANKI_SHADERS_FS_COMMON_VERT_GLSL
  7. // Common code for all vertex shaders of FS
  8. #include "shaders/MsFsCommon.glsl"
  9. // Global resources
  10. #define LIGHT_SET 1
  11. #define LIGHT_SS_BINDING 0
  12. #define LIGHT_TEX_BINDING 1
  13. #define LIGHT_UBO_BINDING 0
  14. #define LIGHT_MINIMAL
  15. #include "shaders/ClusterLightCommon.glsl"
  16. #undef LIGHT_SET
  17. #undef LIGHT_SS_BINDING
  18. #undef LIGHT_TEX_BINDING
  19. // In/out
  20. layout(location = POSITION_LOCATION) in vec3 in_position;
  21. layout(location = SCALE_LOCATION) in float in_scale;
  22. layout(location = ALPHA_LOCATION) in float in_alpha;
  23. layout(location = 0) flat out float out_alpha;
  24. layout(location = 1) out vec2 out_uv;
  25. layout(location = 2) out vec3 out_posViewSpace;
  26. out gl_PerVertex
  27. {
  28. vec4 gl_Position;
  29. };
  30. #define setPositionVec3_DEFINED
  31. void setPositionVec3(in vec3 pos)
  32. {
  33. ANKI_WRITE_POSITION(vec4(pos, 1.0));
  34. }
  35. #define setPositionVec4_DEFINED
  36. void setPositionVec4(in vec4 pos)
  37. {
  38. ANKI_WRITE_POSITION(pos);
  39. }
  40. #define writePositionMvp_DEFINED
  41. void writePositionMvp(in mat4 mvp)
  42. {
  43. ANKI_WRITE_POSITION(mvp * vec4(in_position, 1.0));
  44. }
  45. #define particle_DEFINED
  46. void particle(in mat4 mvp, in mat3 camRot, in mat4 viewMat)
  47. {
  48. const vec2 POSITIONS[4] = vec2[](vec2(-0.5, -0.5), vec2(0.5, -0.5), vec2(-0.5, 0.5), vec2(0.5, 0.5));
  49. vec3 worldPos = camRot * vec3(POSITIONS[gl_VertexID] * in_scale, 0.0) + in_position;
  50. ANKI_WRITE_POSITION(mvp * vec4(worldPos, 1.0));
  51. out_posViewSpace = (viewMat * vec4(worldPos, 1.0)).xyz;
  52. out_alpha = in_alpha;
  53. out_uv = POSITIONS[gl_VertexID] + 0.5;
  54. }
  55. #define writeAlpha_DEFINED
  56. void writeAlpha(in float alpha)
  57. {
  58. out_alpha = alpha;
  59. }
  60. #endif