MsFsCommon.glsl 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright (C) 2009-2016, 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_MS_FS_COMMON_GLSL
  6. #define ANKI_SHADERS_MS_FS_COMMON_GLSL
  7. #include "shaders/Common.glsl"
  8. // Misc
  9. #define COLOR 0
  10. #define DEPTH 1
  11. // Generic functions because materials cannot use operators
  12. #define add_DEFINED
  13. #define add(a, b) ((a) + (b))
  14. #define mul_DEFINED
  15. #define mul(a, b) ((a) * (b))
  16. #define assign_DEFINED
  17. #define assign(a, b) ((a) = (b))
  18. #define vec4ToVec3_DEFINED
  19. #define vec4ToVec3(a) ((a).xyz)
  20. #define vec3ToVec4_DEFINED
  21. #define vec3ToVec4(a, w) (vec4((a), (w)))
  22. #define getW_DEFINED
  23. #define getW(a) ((a).w)
  24. #define setW_DEFINED
  25. #define setW(a, b) ((a).w = (b))
  26. // Read from animated texture
  27. #define readAnimatedTextureRgba_DEFINED
  28. vec4 readAnimatedTextureRgba(sampler2DArray tex, float layerCount, float period, vec2 uv, float time)
  29. {
  30. float layer = mod(time * layerCount / period, layerCount);
  31. return texture(tex, vec3(uv, layer));
  32. }
  33. #endif