Collection of DPF-based plugins for packaging
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
2.1KB

  1. /// @ref core
  2. /// @file glm/detail/_noise.hpp
  3. #pragma once
  4. #include "../vec2.hpp"
  5. #include "../vec3.hpp"
  6. #include "../vec4.hpp"
  7. #include "../common.hpp"
  8. namespace glm{
  9. namespace detail
  10. {
  11. template<typename T>
  12. GLM_FUNC_QUALIFIER T mod289(T const& x)
  13. {
  14. return x - floor(x * (static_cast<T>(1.0) / static_cast<T>(289.0))) * static_cast<T>(289.0);
  15. }
  16. template<typename T>
  17. GLM_FUNC_QUALIFIER T permute(T const& x)
  18. {
  19. return mod289(((x * static_cast<T>(34)) + static_cast<T>(1)) * x);
  20. }
  21. template<typename T, qualifier Q>
  22. GLM_FUNC_QUALIFIER vec<2, T, Q> permute(vec<2, T, Q> const& x)
  23. {
  24. return mod289(((x * static_cast<T>(34)) + static_cast<T>(1)) * x);
  25. }
  26. template<typename T, qualifier Q>
  27. GLM_FUNC_QUALIFIER vec<3, T, Q> permute(vec<3, T, Q> const& x)
  28. {
  29. return mod289(((x * static_cast<T>(34)) + static_cast<T>(1)) * x);
  30. }
  31. template<typename T, qualifier Q>
  32. GLM_FUNC_QUALIFIER vec<4, T, Q> permute(vec<4, T, Q> const& x)
  33. {
  34. return mod289(((x * static_cast<T>(34)) + static_cast<T>(1)) * x);
  35. }
  36. template<typename T>
  37. GLM_FUNC_QUALIFIER T taylorInvSqrt(T const& r)
  38. {
  39. return T(1.79284291400159) - T(0.85373472095314) * r;
  40. }
  41. template<typename T, qualifier Q>
  42. GLM_FUNC_QUALIFIER vec<2, T, Q> taylorInvSqrt(vec<2, T, Q> const& r)
  43. {
  44. return T(1.79284291400159) - T(0.85373472095314) * r;
  45. }
  46. template<typename T, qualifier Q>
  47. GLM_FUNC_QUALIFIER vec<3, T, Q> taylorInvSqrt(vec<3, T, Q> const& r)
  48. {
  49. return T(1.79284291400159) - T(0.85373472095314) * r;
  50. }
  51. template<typename T, qualifier Q>
  52. GLM_FUNC_QUALIFIER vec<4, T, Q> taylorInvSqrt(vec<4, T, Q> const& r)
  53. {
  54. return T(1.79284291400159) - T(0.85373472095314) * r;
  55. }
  56. template<typename T, qualifier Q>
  57. GLM_FUNC_QUALIFIER vec<2, T, Q> fade(vec<2, T, Q> const& t)
  58. {
  59. return (t * t * t) * (t * (t * T(6) - T(15)) + T(10));
  60. }
  61. template<typename T, qualifier Q>
  62. GLM_FUNC_QUALIFIER vec<3, T, Q> fade(vec<3, T, Q> const& t)
  63. {
  64. return (t * t * t) * (t * (t * T(6) - T(15)) + T(10));
  65. }
  66. template<typename T, qualifier Q>
  67. GLM_FUNC_QUALIFIER vec<4, T, Q> fade(vec<4, T, Q> const& t)
  68. {
  69. return (t * t * t) * (t * (t * T(6) - T(15)) + T(10));
  70. }
  71. }//namespace detail
  72. }//namespace glm