FsCommonVert.glsl 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // Copyright (C) 2009-2016, Panagiotis Christopoulos Charitos.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. // Common code for all vertex shaders of FS
  6. #pragma anki include "shaders/MsFsCommon.glsl"
  7. // Global resources
  8. #define LIGHT_SET 1
  9. #define LIGHT_SS_BINDING 0
  10. #define LIGHT_TEX_BINDING 1
  11. #pragma anki include "shaders/LightResources.glsl"
  12. #undef LIGHT_SET
  13. #undef LIGHT_SS_BINDING
  14. #undef LIGHT_TEX_BINDING
  15. // In/out
  16. layout(location = POSITION_LOCATION) in vec3 in_position;
  17. layout(location = SCALE_LOCATION) in float in_scale;
  18. layout(location = ALPHA_LOCATION) in float in_alpha;
  19. layout(location = 0) out vec3 out_vertPosViewSpace;
  20. layout(location = 1) flat out float out_alpha;
  21. out gl_PerVertex
  22. {
  23. vec4 gl_Position;
  24. float gl_PointSize;
  25. };
  26. //==============================================================================
  27. #define setPositionVec3_DEFINED
  28. void setPositionVec3(in vec3 pos)
  29. {
  30. gl_Position = vec4(pos, 1.0);
  31. }
  32. //==============================================================================
  33. #define setPositionVec4_DEFINED
  34. void setPositionVec4(in vec4 pos)
  35. {
  36. gl_Position = pos;
  37. }
  38. //==============================================================================
  39. #define writePositionMvp_DEFINED
  40. void writePositionMvp(in mat4 mvp)
  41. {
  42. gl_Position = mvp * vec4(in_position, 1.0);
  43. }
  44. //==============================================================================
  45. #define particle_DEFINED
  46. void particle(in mat4 mvp)
  47. {
  48. gl_Position = mvp * vec4(in_position, 1);
  49. out_alpha = in_alpha;
  50. gl_PointSize =
  51. in_scale * u_lightingUniforms.rendererSizeTimePad1.x / gl_Position.w;
  52. }
  53. //==============================================================================
  54. #define writeAlpha_DEFINED
  55. void writeAlpha(in float alpha)
  56. {
  57. out_alpha = alpha;
  58. }
  59. //==============================================================================
  60. #define writeVertPosViewSpace_DEFINED
  61. void writeVertPosViewSpace(in mat4 modelViewMat)
  62. {
  63. out_vertPosViewSpace = vec3(modelViewMat * vec4(in_position, 1.0));
  64. }