0.9.6: _noise.hpp Source File

| 0.9.6

- 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
39 namespace glm{
40 namespace detail
41 {
42 template <typename T>
43 GLM_FUNC_QUALIFIER T mod289(T const & x)
44 {
45 return x - floor(x * static_cast<T>(1.0) / static_cast<T>(289.0)) * static_cast<T>(289.0);
46 }
47
48 template <typename T>
49 GLM_FUNC_QUALIFIER T permute(T const & x)
50 {
51 return mod289(((x * static_cast<T>(34)) + static_cast<T>(1)) * x);
52 }
53
54 template <typename T, precision P>
55 GLM_FUNC_QUALIFIER tvec2<T, P> permute(tvec2<T, P> const & x)
56 {
57 return mod289(((x * static_cast<T>(34)) + static_cast<T>(1)) * x);
58 }
59
60 template <typename T, precision P>
61 GLM_FUNC_QUALIFIER tvec3<T, P> permute(tvec3<T, P> const & x)
62 {
63 return mod289(((x * static_cast<T>(34)) + static_cast<T>(1)) * x);
64 }
65
66 template <typename T, precision P>
67 GLM_FUNC_QUALIFIER tvec4<T, P> permute(tvec4<T, P> const & x)
68 {
69 return mod289(((x * static_cast<T>(34)) + static_cast<T>(1)) * x);
70 }
71 /*
72 template <typename T, precision P, template<typename> class vecType>
73 GLM_FUNC_QUALIFIER vecType<T, P> permute(vecType<T, P> const & x)
74 {
75 return mod289(((x * T(34)) + T(1)) * x);
76 }
77 */
78 template <typename T>
79 GLM_FUNC_QUALIFIER T taylorInvSqrt(T const & r)
80 {
81 return T(1.79284291400159) - T(0.85373472095314) * r;
82 }
83
84 template <typename T, precision P>
85 GLM_FUNC_QUALIFIER tvec2<T, P> taylorInvSqrt(tvec2<T, P> const & r)
86 {
87 return T(1.79284291400159) - T(0.85373472095314) * r;
88 }
89
90 template <typename T, precision P>
91 GLM_FUNC_QUALIFIER tvec3<T, P> taylorInvSqrt(tvec3<T, P> const & r)
92 {
93 return T(1.79284291400159) - T(0.85373472095314) * r;
94 }
95
96 template <typename T, precision P>
97 GLM_FUNC_QUALIFIER tvec4<T, P> taylorInvSqrt(tvec4<T, P> const & r)
98 {
99 return T(1.79284291400159) - T(0.85373472095314) * r;
100 }
101 /*
102 template <typename T, precision P, template<typename> class vecType>
103 GLM_FUNC_QUALIFIER vecType<T, P> taylorInvSqrt(vecType<T, P> const & r)
104 {
105 return T(1.79284291400159) - T(0.85373472095314) * r;
106 }
107 */
108
109 template <typename T, precision P>
110 GLM_FUNC_QUALIFIER tvec2<T, P> fade(tvec2<T, P> const & t)
111 {
112 return (t * t * t) * (t * (t * T(6) - T(15)) + T(10));
113 }
114
115 template <typename T, precision P>
116 GLM_FUNC_QUALIFIER tvec3<T, P> fade(tvec3<T, P> const & t)
117 {
118 return (t * t * t) * (t * (t * T(6) - T(15)) + T(10));
119 }
120
121 template <typename T, precision P>
122 GLM_FUNC_QUALIFIER tvec4<T, P> fade(tvec4<T, P> const & t)
123 {
124 return (t * t * t) * (t * (t * T(6) - T(15)) + T(10));
125 }
126 /*
127 template <typename T, precision P, template <typename> class vecType>
128 GLM_FUNC_QUALIFIER vecType<T, P> fade(vecType<T, P> const & t)
129 {
130 return (t * t * t) * (t * (t * T(6) - T(15)) + T(10));
131 }
132 */
133 }//namespace detail
134 }//namespace glm
135
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:39