| 0.9.7

- Main Page
- Modules
- Files

- File List

_noise.hpp
Go to the documentation of this file.
1
33 #pragma once
34
35 #include "../vec2.hpp"
36 #include "../vec3.hpp"
37 #include "../vec4.hpp"
38 #include "../common.hpp"
39
40 namespace glm{
41 namespace detail
42 {
43 template <typename T>
44 GLM_FUNC_QUALIFIER T mod289(T const & x)
45 {
46 return x - floor(x * static_cast<T>(1.0) / static_cast<T>(289.0)) * static_cast<T>(289.0);
47 }
48
49 template <typename T>
50 GLM_FUNC_QUALIFIER T permute(T const & x)
51 {
52 return mod289(((x * static_cast<T>(34)) + static_cast<T>(1)) * x);
53 }
54
55 template <typename T, precision P>
56 GLM_FUNC_QUALIFIER tvec2<T, P> permute(tvec2<T, P> const & x)
57 {
58 return mod289(((x * static_cast<T>(34)) + static_cast<T>(1)) * x);
59 }
60
61 template <typename T, precision P>
62 GLM_FUNC_QUALIFIER tvec3<T, P> permute(tvec3<T, P> const & x)
63 {
64 return mod289(((x * static_cast<T>(34)) + static_cast<T>(1)) * x);
65 }
66
67 template <typename T, precision P>
68 GLM_FUNC_QUALIFIER tvec4<T, P> permute(tvec4<T, P> const & x)
69 {
70 return mod289(((x * static_cast<T>(34)) + static_cast<T>(1)) * x);
71 }
72 /*
73 template <typename T, precision P, template<typename> class vecType>
74 GLM_FUNC_QUALIFIER vecType<T, P> permute(vecType<T, P> const & x)
75 {
76 return mod289(((x * T(34)) + T(1)) * x);
77 }
78 */
79 template <typename T>
80 GLM_FUNC_QUALIFIER T taylorInvSqrt(T const & r)
81 {
82 return T(1.79284291400159) - T(0.85373472095314) * r;
83 }
84
85 template <typename T, precision P>
86 GLM_FUNC_QUALIFIER tvec2<T, P> taylorInvSqrt(tvec2<T, P> const & r)
87 {
88 return T(1.79284291400159) - T(0.85373472095314) * r;
89 }
90
91 template <typename T, precision P>
92 GLM_FUNC_QUALIFIER tvec3<T, P> taylorInvSqrt(tvec3<T, P> const & r)
93 {
94 return T(1.79284291400159) - T(0.85373472095314) * r;
95 }
96
97 template <typename T, precision P>
98 GLM_FUNC_QUALIFIER tvec4<T, P> taylorInvSqrt(tvec4<T, P> const & r)
99 {
100 return T(1.79284291400159) - T(0.85373472095314) * r;
101 }
102 /*
103 template <typename T, precision P, template<typename> class vecType>
104 GLM_FUNC_QUALIFIER vecType<T, P> taylorInvSqrt(vecType<T, P> const & r)
105 {
106 return T(1.79284291400159) - T(0.85373472095314) * r;
107 }
108 */
109
110 template <typename T, precision P>
111 GLM_FUNC_QUALIFIER tvec2<T, P> fade(tvec2<T, P> const & t)
112 {
113 return (t * t * t) * (t * (t * T(6) - T(15)) + T(10));
114 }
115
116 template <typename T, precision P>
117 GLM_FUNC_QUALIFIER tvec3<T, P> fade(tvec3<T, P> const & t)
118 {
119 return (t * t * t) * (t * (t * T(6) - T(15)) + T(10));
120 }
121
122 template <typename T, precision P>
123 GLM_FUNC_QUALIFIER tvec4<T, P> fade(tvec4<T, P> const & t)
124 {
125 return (t * t * t) * (t * (t * T(6) - T(15)) + T(10));
126 }
127 /*
128 template <typename T, precision P, template <typename> class vecType>
129 GLM_FUNC_QUALIFIER vecType<T, P> fade(vecType<T, P> const & t)
130 {
131 return (t * t * t) * (t * (t * T(6) - T(15)) + T(10));
132 }
133 */
134 }//namespace detail
135 }//namespace glm
136
glm::floor
GLM_FUNC_DECL vecType< T, P > floor(vecType< T, P > const &x)
Returns a value equal to the nearest integer that is less then or equal to x.
glm
Definition: _noise.hpp:40