Home | History | Annotate | Download | only in gtc

Lines Matching full:detail

37 #include "../detail/_noise.hpp"
43 GLM_FUNC_QUALIFIER detail::tvec4<T, P> grad4(T const & j, detail::tvec4<T, P> const & ip)
45 detail::tvec3<T, P> pXYZ = floor(fract(detail::tvec3<T, P>(j) * detail::tvec3<T, P>(ip)) * T(7)) * ip[2] - T(1);
46 T pW = static_cast<T>(1.5) - dot(abs(pXYZ), detail::tvec3<T, P>(1));
47 detail::tvec4<T, P> s = detail::tvec4<T, P>(lessThan(detail::tvec4<T, P>(pXYZ, pW), detail::tvec4<T, P>(0.0)));
48 pXYZ = pXYZ + (detail::tvec3<T, P>(s) * T(2) - T(1)) * s.w;
49 return detail::tvec4<T, P>(pXYZ, pW);
55 GLM_FUNC_QUALIFIER T perlin(detail::tvec2<T, P> const & Position)
57 detail::tvec4<T, P> Pi = glm::floor(detail::tvec4<T, P>(Position.x, Position.y, Position.x, Position.y)) + detail::tvec4<T, P>(0.0, 0.0, 1.0, 1.0);
58 detail::tvec4<T, P> Pf = glm::fract(detail::tvec4<T, P>(Position.x, Position.y, Position.x, Position.y)) - detail::tvec4<T, P>(0.0, 0.0, 1.0, 1.0);
59 Pi = mod(Pi, detail::tvec4<T, P>(289)); // To avoid truncation effects in permutation
60 detail::tvec4<T, P> ix(Pi.x, Pi.z, Pi.x, Pi.z);
61 detail::tvec4<T, P> iy(Pi.y, Pi.y, Pi.w, Pi.w);
62 detail::tvec4<T, P> fx(Pf.x, Pf.z, Pf.x, Pf.z);
63 detail::tvec4<T, P> fy(Pf.y, Pf.y, Pf.w, Pf.w);
65 detail::tvec4<T, P> i = detail::permute(detail::permute(ix) + iy);
67 detail::tvec4<T, P> gx = static_cast<T>(2) * glm::fract(i / T(41)) - T(1);
68 detail::tvec4<T, P> gy = glm::abs(gx) - T(0.5);
69 detail::tvec4<T, P> tx = glm::floor(gx + T(0.5));
72 detail::tvec2<T, P> g00(gx.x, gy.x);
73 detail::tvec2<T, P> g10(gx.y, gy.y);
74 detail::tvec2<T, P> g01(gx.z, gy.z);
75 detail::tvec2<T, P> g11(gx.w, gy.w);
77 detail::tvec4<T, P> norm = taylorInvSqrt(detail::tvec4<T, P>(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11)));
83 T n00 = dot(g00, detail::tvec2<T, P>(fx.x, fy.x));
84 T n10 = dot(g10, detail::tvec2<T, P>(fx.y, fy.y));
85 T n01 = dot(g01, detail::tvec2<T, P>(fx.z, fy.z));
86 T n11 = dot(g11, detail::tvec2<T, P>(fx.w, fy.w));
88 detail::tvec2<T, P> fade_xy = fade(detail::tvec2<T, P>(Pf.x, Pf.y));
89 detail::tvec2<T, P> n_x = mix(detail::tvec2<T, P>(n00, n01), detail::tvec2<T, P>(n10, n11), fade_xy.x);
96 GLM_FUNC_QUALIFIER T perlin(detail::tvec3<T, P> const & Position)
98 detail::tvec3<T, P> Pi0 = floor(Position); // Integer part for indexing
99 detail::tvec3<T, P> Pi1 = Pi0 + T(1); // Integer part + 1
102 detail::tvec3<T, P> Pf0 = fract(Position); // Fractional part for interpolation
103 detail::tvec3<T, P> Pf1 = Pf0 - T(1); // Fractional part - 1.0
104 detail::tvec4<T, P> ix(Pi0.x, Pi1.x, Pi0.x, Pi1.x);
105 detail::tvec4<T, P> iy = detail::tvec4<T, P>(detail::tvec2<T, P>(Pi0.y), detail::tvec2<T, P>(Pi1.y));
106 detail::tvec4<T, P> iz0(Pi0.z);
107 detail::tvec4<T, P> iz1(Pi1.z);
109 detail::tvec4<T, P> ixy = detail::permute(detail::permute(ix) + iy);
110 detail::tvec4<T, P> ixy0 = detail::permute(ixy + iz0);
111 detail::tvec4<T, P> ixy1 = detail::permute(ixy + iz1);
113 detail::tvec4<T, P> gx0 = ixy0 * T(1.0 / 7.0);
114 detail::tvec4<T, P> gy0 = fract(floor(gx0) * T(1.0 / 7.0)) - T(0.5);
116 detail::tvec4<T, P> gz0 = detail::tvec4<T, P>(0.5) - abs(gx0) - abs(gy0);
117 detail::tvec4<T, P> sz0 = step(gz0, detail::tvec4<T, P>(0.0));
121 detail::tvec4<T, P> gx1 = ixy1 * T(1.0 / 7.0);
122 detail::tvec4<T, P> gy1 = fract(floor(gx1) * T(1.0 / 7.0)) - T(0.5);
124 detail::tvec4<T, P> gz1 = detail::tvec4<T, P>(0.5) - abs(gx1) - abs(gy1);
125 detail::tvec4<T, P> sz1 = step(gz1, detail::tvec4<T, P>(0.0));
129 detail::tvec3<T, P> g000(gx0.x, gy0.x, gz0.x);
130 detail::tvec3<T, P> g100(gx0.y, gy0.y, gz0.y);
131 detail::tvec3<T, P> g010(gx0.z, gy0.z, gz0.z);
132 detail::tvec3<T, P> g110(gx0.w, gy0.w, gz0.w);
133 detail::tvec3<T, P> g001(gx1.x, gy1.x, gz1.x);
134 detail::tvec3<T, P> g101(gx1.y, gy1.y, gz1.y);
135 detail::tvec3<T, P> g011(gx1.z, gy1.z, gz1.z);
136 detail::tvec3<T, P> g111(gx1.w, gy1.w, gz1.w);
138 detail::tvec4<T, P> norm0 = detail::taylorInvSqrt(detail::tvec4<T, P>(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));
143 detail::tvec4<T, P> norm1 = detail::taylorInvSqrt(detail::tvec4<T, P>(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));
150 T n100 = dot(g100, detail::tvec3<T, P>(Pf1.x, Pf0.y, Pf0.z));
151 T n010 = dot(g010, detail::tvec3<T, P>(Pf0.x, Pf1.y, Pf0.z));
152 T n110 = dot(g110, detail::tvec3<T, P>(Pf1.x, Pf1.y, Pf0.z));
153 T n001 = dot(g001, detail::tvec3<T, P>(Pf0.x, Pf0.y, Pf1.z));
154 T n101 = dot(g101, detail::tvec3<T, P>(Pf1.x, Pf0.y, Pf1.z));
155 T n011 = dot(g011, detail::tvec3<T, P>(Pf0.x, Pf1.y, Pf1.z));
158 detail::tvec3<T, P> fade_xyz = fade(Pf0);
159 detail::tvec4<T, P> n_z = mix(detail::tvec4<T, P>(n000, n100, n010, n110), detail::tvec4<T, P>(n001, n101, n011, n111), fade_xyz.z);
160 detail::tvec2<T, P> n_yz = mix(detail::tvec2<T, P>(n_z.x, n_z.y), detail::tvec2<T, P>(n_z.z, n_z.w), fade_xyz.y);
167 GLM_FUNC_QUALIFIER T perlin(detail::tvec3<T, P> const & P)
169 detail::tvec3<T, P> Pi0 = floor(P); // Integer part for indexing
170 detail::tvec3<T, P> Pi1 = Pi0 + T(1); // Integer part + 1
173 detail::tvec3<T, P> Pf0 = fract(P); // Fractional part for interpolation
174 detail::tvec3<T, P> Pf1 = Pf0 - T(1); // Fractional part - 1.0
175 detail::tvec4<T, P> ix(Pi0.x, Pi1.x, Pi0.x, Pi1.x);
176 detail::tvec4<T, P> iy(Pi0.y, Pi0.y, Pi1.y, Pi1.y);
177 detail::tvec4<T, P> iz0(Pi0.z);
178 detail::tvec4<T, P> iz1(Pi1.z);
180 detail::tvec4<T, P> ixy = permute(permute(ix) + iy);
181 detail::tvec4<T, P> ixy0 = permute(ixy + iz0);
182 detail::tvec4<T, P> ixy1 = permute(ixy + iz1);
184 detail::tvec4<T, P> gx0 = ixy0 / T(7);
185 detail::tvec4<T, P> gy0 = fract(floor(gx0) / T(7)) - T(0.5);
187 detail::tvec4<T, P> gz0 = detail::tvec4<T, P>(0.5) - abs(gx0) - abs(gy0);
188 detail::tvec4<T, P> sz0 = step(gz0, detail::tvec4<T, P>(0.0));
192 detail::tvec4<T, P> gx1 = ixy1 / T(7);
193 detail::tvec4<T, P> gy1 = fract(floor(gx1) / T(7)) - T(0.5);
195 detail::tvec4<T, P> gz1 = detail::tvec4<T, P>(0.5) - abs(gx1) - abs(gy1);
196 detail::tvec4<T, P> sz1 = step(gz1, detail::tvec4<T, P>(0.0));
200 detail::tvec3<T, P> g000(gx0.x, gy0.x, gz0.x);
201 detail::tvec3<T, P> g100(gx0.y, gy0.y, gz0.y);
202 detail::tvec3<T, P> g010(gx0.z, gy0.z, gz0.z);
203 detail::tvec3<T, P> g110(gx0.w, gy0.w, gz0.w);
204 detail::tvec3<T, P> g001(gx1.x, gy1.x, gz1.x);
205 detail::tvec3<T, P> g101(gx1.y, gy1.y, gz1.y);
206 detail::tvec3<T, P> g011(gx1.z, gy1.z, gz1.z);
207 detail::tvec3<T, P> g111(gx1.w, gy1.w, gz1.w);
209 detail::tvec4<T, P> norm0 = taylorInvSqrt(detail::tvec4<T, P>(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));
214 detail::tvec4<T, P> norm1 = taylorInvSqrt(detail::tvec4<T, P>(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));
221 T n100 = dot(g100, detail::tvec3<T, P>(Pf1.x, Pf0.y, Pf0.z));
222 T n010 = dot(g010, detail::tvec3<T, P>(Pf0.x, Pf1.y, Pf0.z));
223 T n110 = dot(g110, detail::tvec3<T, P>(Pf1.x, Pf1.y, Pf0.z));
224 T n001 = dot(g001, detail::tvec3<T, P>(Pf0.x, Pf0.y, Pf1.z));
225 T n101 = dot(g101, detail::tvec3<T, P>(Pf1.x, Pf0.y, Pf1.z));
226 T n011 = dot(g011, detail::tvec3<T, P>(Pf0.x, Pf1.y, Pf1.z));
229 detail::tvec3<T, P> fade_xyz = fade(Pf0);
230 detail::tvec4<T, P> n_z = mix(detail::tvec4<T, P>(n000, n100, n010, n110), detail::tvec4<T, P>(n001, n101, n011, n111), fade_xyz.z);
231 detail::tvec2<T, P> n_yz = mix(
232 detail::tvec2<T, P>(n_z.x, n_z.y),
233 detail::tvec2<T, P>(n_z.z, n_z.w), fade_xyz.y);
240 GLM_FUNC_QUALIFIER T perlin(detail::tvec4<T, P> const & Position)
242 detail::tvec4<T, P> Pi0 = floor(Position); // Integer part for indexing
243 detail::tvec4<T, P> Pi1 = Pi0 + T(1); // Integer part + 1
244 Pi0 = mod(Pi0, detail::tvec4<T, P>(289));
245 Pi1 = mod(Pi1, detail::tvec4<T, P>(289));
246 detail::tvec4<T, P> Pf0 = fract(Position); // Fractional part for interpolation
247 detail::tvec4<T, P> Pf1 = Pf0 - T(1); // Fractional part - 1.0
248 detail::tvec4<T, P> ix(Pi0.x, Pi1.x, Pi0.x, Pi1.x);
249 detail::tvec4<T, P> iy(Pi0.y, Pi0.y, Pi1.y, Pi1.y);
250 detail::tvec4<T, P> iz0(Pi0.z);
251 detail::tvec4<T, P> iz1(Pi1.z);
252 detail::tvec4<T, P> iw0(Pi0.w);
253 detail::tvec4<T, P> iw1(Pi1.w);
255 detail::tvec4<T, P> ixy = detail::permute(detail::permute(ix) + iy);
256 detail::tvec4<T, P> ixy0 = detail::permute(ixy + iz0);
257 detail::tvec4<T, P> ixy1 = detail::permute(ixy + iz1);
258 detail::tvec4<T, P> ixy00 = detail::permute(ixy0 + iw0);
259 detail::tvec4<T, P> ixy01 = detail::permute(ixy0 + iw1);
260 detail::tvec4<T, P> ixy10 = detail::permute(ixy1 + iw0);
261 detail::tvec4<T, P> ixy11 = detail::permute(ixy1 + iw1);
263 detail::tvec4<T, P> gx00 = ixy00 / T(7);
264 detail::tvec4<T, P> gy00 = floor(gx00) / T(7);
265 detail::tvec4<T, P> gz00 = floor(gy00) / T(6);
269 detail::tvec4<T, P> gw00 = detail::tvec4<T, P>(0.75) - abs(gx00) - abs(gy00) - abs(gz00);
270 detail::tvec4<T, P> sw00 = step(gw00, detail::tvec4<T, P>(0.0));
274 detail::tvec4<T, P> gx01 = ixy01 / T(7);
275 detail::tvec4<T, P> gy01 = floor(gx01) / T(7);
276 detail::tvec4<T, P> gz01 = floor(gy01) / T(6);
280 detail::tvec4<T, P> gw01 = detail::tvec4<T, P>(0.75) - abs(gx01) - abs(gy01) - abs(gz01);
281 detail::tvec4<T, P> sw01 = step(gw01, detail::tvec4<T, P>(0.0));
285 detail::tvec4<T, P> gx10 = ixy10 / T(7);
286 detail::tvec4<T, P> gy10 = floor(gx10) / T(7);
287 detail::tvec4<T, P> gz10 = floor(gy10) / T(6);
291 detail::tvec4<T, P> gw10 = detail::tvec4<T, P>(0.75) - abs(gx10) - abs(gy10) - abs(gz10);
292 detail::tvec4<T, P> sw10 = step(gw10, detail::tvec4<T, P>(0));
296 detail::tvec4<T, P> gx11 = ixy11 / T(7);
297 detail::tvec4<T, P> gy11 = floor(gx11) / T(7);
298 detail::tvec4<T, P> gz11 = floor(gy11) / T(6);
302 detail::tvec4<T, P> gw11 = detail::tvec4<T, P>(0.75) - abs(gx11) - abs(gy11) - abs(gz11);
303 detail::tvec4<T, P> sw11 = step(gw11, detail::tvec4<T, P>(0.0));
307 detail::tvec4<T, P> g0000(gx00.x, gy00.x, gz00.x, gw00.x);
308 detail::tvec4<T, P> g1000(gx00.y, gy00.y, gz00.y, gw00.y);
309 detail::tvec4<T, P> g0100(gx00.z, gy00.z, gz00.z, gw00.z);
310 detail::tvec4<T, P> g1100(gx00.w, gy00.w, gz00.w, gw00.w);
311 detail::tvec4<T, P> g0010(gx10.x, gy10.x, gz10.x, gw10.x);
312 detail::tvec4<T, P> g1010(gx10.y, gy10.y, gz10.y, gw10.y);
313 detail::tvec4<T, P> g0110(gx10.z, gy10.z, gz10.z, gw10.z);
314 detail::tvec4<T, P> g1110(gx10.w, gy10.w, gz10.w, gw10.w);
315 detail::tvec4<T, P> g0001(gx01.x, gy01.x, gz01.x, gw01.x);
316 detail::tvec4<T, P> g1001(gx01.y, gy01.y, gz01.y, gw01.y);
317 detail::tvec4<T, P> g0101(gx01.z, gy01.z, gz01.z, gw01.z);
318 detail::tvec4<T, P> g1101(gx01.w, gy01.w, gz01.w, gw01.w);
319 detail::tvec4<T, P> g0011(gx11.x, gy11.x, gz11.x, gw11.x);
320 detail::tvec4<T, P> g1011(gx11.y, gy11.y, gz11.y, gw11.y);
321 detail::tvec4<T, P> g0111(gx11.z, gy11.z, gz11.z, gw11.z);
322 detail::tvec4<T, P> g1111(gx11.w, gy11.w, gz11.w, gw11.w);
324 detail::tvec4<T, P> norm00 = detail::taylorInvSqrt(detail::tvec4<T, P>(dot(g0000, g0000), dot(g0100, g0100), dot(g1000, g1000), dot(g1100, g1100)));
330 detail::tvec4<T, P> norm01 = detail::taylorInvSqrt(detail::tvec4<T, P>(dot(g0001, g0001), dot(g0101, g0101), dot(g1001, g1001), dot(g1101, g1101)));
336 detail::tvec4<T, P> norm10 = detail::taylorInvSqrt(detail::tvec4<T, P>(dot(g0010, g0010), dot(g0110, g0110), dot(g1010, g1010), dot(g1110, g1110)));
342 detail::tvec4<T, P> norm11 = detail::taylorInvSqrt(detail::tvec4<T, P>(dot(g0011, g0011), dot(g0111, g0111), dot(g1011, g1011), dot(g1111, g1111)));
349 T n1000 = dot(g1000, detail::tvec4<T, P>(Pf1.x, Pf0.y, Pf0.z, Pf0.w));
350 T n0100 = dot(g0100, detail::tvec4<T, P>(Pf0.x, Pf1.y, Pf0.z, Pf0.w));
351 T n1100 = dot(g1100, detail::tvec4<T, P>(Pf1.x, Pf1.y, Pf0.z, Pf0.w));
352 T n0010 = dot(g0010, detail::tvec4<T, P>(Pf0.x, Pf0.y, Pf1.z, Pf0.w));
353 T n1010 = dot(g1010, detail::tvec4<T, P>(Pf1.x, Pf0.y, Pf1.z, Pf0.w));
354 T n0110 = dot(g0110, detail::tvec4<T, P>(Pf0.x, Pf1.y, Pf1.z, Pf0.w));
355 T n1110 = dot(g1110, detail::tvec4<T, P>(Pf1.x, Pf1.y, Pf1.z, Pf0.w));
356 T n0001 = dot(g0001, detail::tvec4<T, P>(Pf0.x, Pf0.y, Pf0.z, Pf1.w));
357 T n1001 = dot(g1001, detail
358 T n0101 = dot(g0101, detail::tvec4<T, P>(Pf0.x, Pf1.y, Pf0.z, Pf1.w));
359 T n1101 = dot(g1101, detail::tvec4<T, P>(Pf1.x, Pf1.y, Pf0.z, Pf1.w));
360 T n0011 = dot(g0011, detail::tvec4<T, P>(Pf0.x, Pf0.y, Pf1.z, Pf1.w));
361 T n1011 = dot(g1011, detail::tvec4<T, P>(Pf1.x, Pf0.y, Pf1.z, Pf1.w));
362 T n0111 = dot(g0111, detail::tvec4<T, P>(Pf0.x, Pf1.y, Pf1.z, Pf1.w));
365 detail::tvec4<T, P> fade_xyzw = fade(Pf0);
366 detail::tvec4<T, P> n_0w = mix(detail::tvec4<T, P>(n0000, n1000, n0100, n1100), detail::tvec4<T, P>(n0001, n1001, n0101, n1101), fade_xyzw.w);
367 detail::tvec4<T, P> n_1w = mix(detail::tvec4<T, P>(n0010, n1010, n0110, n1110), detail::tvec4<T, P>(n0011, n1011, n0111, n1111), fade_xyzw.w);
368 detail::tvec4<T, P> n_zw = mix(n_0w, n_1w, fade_xyzw.z);
369 detail::tvec2<T, P> n_yzw = mix(detail::tvec2<T, P>(n_zw.x, n_zw.y), detail::tvec2<T, P>(n_zw.z, n_zw.w), fade_xyzw.y);
376 GLM_FUNC_QUALIFIER T perlin(detail::tvec2<T, P> const & Position, detail::tvec2<T, P> const & rep)
378 detail::tvec4<T, P> Pi = floor(detail::tvec4<T, P>(Position.x, Position.y, Position.x, Position.y)) + detail::tvec4<T, P>(0.0, 0.0, 1.0, 1.0);
379 detail::tvec4<T, P> Pf = fract(detail::tvec4<T, P>(Position.x, Position.y, Position.x, Position.y)) - detail::tvec4<T, P>(0.0, 0.0, 1.0, 1.0);
380 Pi = mod(Pi, detail::tvec4<T, P>(rep.x, rep.y, rep.x, rep.y)); // To create noise with explicit period
381 Pi = mod(Pi, detail::tvec4<T, P>(289)); // To avoid truncation effects in permutation
382 detail::tvec4<T, P> ix(Pi.x, Pi.z, Pi.x, Pi.z);
383 detail::tvec4<T, P> iy(Pi.y, Pi.y, Pi.w, Pi.w);
384 detail::tvec4<T, P> fx(Pf.x, Pf.z, Pf.x, Pf.z);
385 detail::tvec4<T, P> fy(Pf.y, Pf.y, Pf.w, Pf.w);
387 detail::tvec4<T, P> i = detail::permute(detail::permute(ix) + iy);
389 detail::tvec4<T, P> gx = static_cast<T>(2) * fract(i / T(41)) - T(1);
390 detail::tvec4<T, P> gy = abs(gx) - T(0.5);
391 detail::tvec4<T, P> tx = floor(gx + T(0.5));
394 detail::tvec2<T, P> g00(gx.x, gy.x);
395 detail::tvec2<T, P> g10(gx.y, gy.y);
396 detail::tvec2<T, P> g01(gx.z, gy.z);
397 detail::tvec2<T, P> g11(gx.w, gy.w);
399 detail::tvec4<T, P> norm = detail::taylorInvSqrt(detail::tvec4<T, P>(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11)));
405 T n00 = dot(g00, detail::tvec2<T, P>(fx.x, fy.x));
406 T n10 = dot(g10, detail::tvec2<T, P>(fx.y, fy.y));
407 T n01 = dot(g01, detail::tvec2<T, P>(fx.z, fy.z));
408 T n11 = dot(g11, detail::tvec2<T, P>(fx.w, fy.w));
410 detail::tvec2<T, P> fade_xy = fade(detail::tvec2<T, P>(Pf.x, Pf.y));
411 detail::tvec2<T, P> n_x = mix(detail::tvec2<T, P>(n00, n01), detail::tvec2<T, P>(n10, n11), fade_xy.x);
418 GLM_FUNC_QUALIFIER T perlin(detail::tvec3<T, P> const & Position, detail::tvec3<T, P> const & rep)
420 detail::tvec3<T, P> Pi0 = mod(floor(Position), rep); // Integer part, modulo period
421 detail::tvec3<T, P> Pi1 = mod(Pi0 + detail::tvec3<T, P>(T(1)), rep); // Integer part + 1, mod period
422 Pi0 = mod(Pi0, detail::tvec3<T, P>(289));
423 Pi1 = mod(Pi1, detail::tvec3<T, P>(289));
424 detail::tvec3<T, P> Pf0 = fract(Position); // Fractional part for interpolation
425 detail::tvec3<T, P> Pf1 = Pf0 - detail::tvec3<T, P>(T(1)); // Fractional part - 1.0
426 detail::tvec4<T, P> ix = detail::tvec4<T, P>(Pi0.x, Pi1.x, Pi0.x, Pi1.x);
427 detail::tvec4<T, P> iy = detail::tvec4<T, P>(Pi0.y, Pi0.y, Pi1.y, Pi1.y);
428 detail::tvec4<T, P> iz0(Pi0.z);
429 detail::tvec4<T, P> iz1(Pi1.z);
431 detail::tvec4<T, P> ixy = detail::permute(detail::permute(ix) + iy);
432 detail::tvec4<T, P> ixy0 = detail::permute(ixy + iz0);
433 detail::tvec4<T, P> ixy1 = detail::permute(ixy + iz1);
435 detail::tvec4<T, P> gx0 = ixy0 / T(7);
436 detail::tvec4<T, P> gy0 = fract(floor(gx0) / T(7)) - T(0.5);
438 detail::tvec4<T, P> gz0 = detail::tvec4<T, P>(0.5) - abs(gx0) - abs(gy0);
439 detail::tvec4<T, P> sz0 = step(gz0, detail::tvec4<T, P>(0));
443 detail::tvec4<T, P> gx1 = ixy1 / T(7);
444 detail::tvec4<T, P> gy1 = fract(floor(gx1) / T(7)) - T(0.5);
446 detail::tvec4<T, P> gz1 = detail::tvec4<T, P>(0.5) - abs(gx1) - abs(gy1);
447 detail::tvec4<T, P> sz1 = step(gz1, detail::tvec4<T, P>(T(0)));
451 detail::tvec3<T, P> g000 = detail::tvec3<T, P>(gx0.x, gy0.x, gz0.x);
452 detail::tvec3<T, P> g100 = detail::tvec3<T, P>(gx0.y, gy0.y, gz0.y);
453 detail::tvec3<T, P> g010 = detail::tvec3<T, P>(gx0.z, gy0.z, gz0.z);
454 detail::tvec3<T, P> g110 = detail::tvec3<T, P>(gx0.w, gy0.w, gz0.w);
455 detail::tvec3<T, P> g001 = detail::tvec3<T, P>(gx1.x, gy1.x, gz1.x);
456 detail::tvec3<T, P> g101 = detail::tvec3<T, P>(gx1.y, gy1.y, gz1.y);
457 detail::tvec3<T, P> g011 = detail::tvec3<T, P>(gx1.z, gy1.z, gz1.z);
458 detail::tvec3<T, P> g111 = detail::tvec3<T, P>(gx1.w, gy1.w, gz1.w);
460 detail::tvec4<T, P> norm0 = detail::taylorInvSqrt(detail::tvec4<T, P>(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));
465 detail::tvec4<T, P> norm1 = detail::taylorInvSqrt(detail::tvec4<T, P>(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));
472 T n100 = dot(g100, detail::tvec3<T, P>(Pf1.x, Pf0.y, Pf0.z));
473 T n010 = dot(g010, detail::tvec3<T, P>(Pf0.x, Pf1.y, Pf0.z));
474 T n110 = dot(g110, detail::tvec3<T, P>(Pf1.x, Pf1.y, Pf0.z));
475 T n001 = dot(g001, detail::tvec3<T, P>(Pf0.x, Pf0.y, Pf1.z));
476 T n101 = dot(g101, detail::tvec3<T, P>(Pf1.x, Pf0.y, Pf1.z));
477 T n011 = dot(g011, detail::tvec3<T, P>(Pf0.x, Pf1.y, Pf1.z));
480 detail::tvec3<T, P> fade_xyz = fade(Pf0);
481 detail::tvec4<T, P> n_z = mix(detail::tvec4<T, P>(n000, n100, n010, n110), detail::tvec4<T, P>(n001, n101, n011, n111), fade_xyz.z);
482 detail::tvec2<T, P> n_yz = mix(detail::tvec2<T, P>(n_z.x, n_z.y), detail::tvec2<T, P>(n_z.z, n_z.w), fade_xyz.y);
489 GLM_FUNC_QUALIFIER T perlin(detail::tvec4<T, P> const & Position, detail::tvec4<T, P> const & rep)
491 detail::tvec4<T, P> Pi0 = mod(floor(Position), rep); // Integer part modulo rep
492 detail::tvec4<T, P> Pi1 = mod(Pi0 + T(1), rep); // Integer part + 1 mod rep
493 detail::tvec4<T, P> Pf0 = fract(Position); // Fractional part for interpolation
494 detail::tvec4<T, P> Pf1 = Pf0 - T(1); // Fractional part - 1.0
495 detail::tvec4<T, P> ix = detail::tvec4<T, P>(Pi0.x, Pi1.x, Pi0.x, Pi1.x);
496 detail::tvec4<T, P> iy = detail::tvec4<T, P>(Pi0.y, Pi0.y, Pi1.y, Pi1.y);
497 detail::tvec4<T, P> iz0(Pi0.z);
498 detail::tvec4<T, P> iz1(Pi1.z);
499 detail::tvec4<T, P> iw0(Pi0.w);
500 detail::tvec4<T, P> iw1(Pi1.w);
502 detail::tvec4<T, P> ixy = detail::permute(detail::permute(ix) + iy);
503 detail::tvec4<T, P> ixy0 = detail::permute(ixy + iz0);
504 detail::tvec4<T, P> ixy1 = detail::permute(ixy + iz1);
505 detail::tvec4<T, P> ixy00 = detail::permute(ixy0 + iw0);
506 detail::tvec4<T, P> ixy01 = detail::permute(ixy0 + iw1);
507 detail::tvec4<T, P> ixy10 = detail::permute(ixy1 + iw0);
508 detail::tvec4<T, P> ixy11 = detail::permute(ixy1 + iw1);
510 detail::tvec4<T, P> gx00 = ixy00 / T(7);
511 detail::tvec4<T, P> gy00 = floor(gx00) / T(7);
512 detail::tvec4<T, P> gz00 = floor(gy00) / T(6);
516 detail::tvec4<T, P> gw00 = detail::tvec4<T, P>(0.75) - abs(gx00) - abs(gy00) - abs(gz00);
517 detail::tvec4<T, P> sw00 = step(gw00, detail::tvec4<T, P>(0));
521 detail::tvec4<T, P> gx01 = ixy01 / T(7);
522 detail::tvec4<T, P> gy01 = floor(gx01) / T(7);
523 detail::tvec4<T, P> gz01 = floor(gy01) / T(6);
527 detail::tvec4<T, P> gw01 = detail::tvec4<T, P>(0.75) - abs(gx01) - abs(gy01) - abs(gz01);
528 detail::tvec4<T, P> sw01 = step(gw01, detail::tvec4<T, P>(0.0));
532 detail::tvec4<T, P> gx10 = ixy10 / T(7);
533 detail::tvec4<T, P> gy10 = floor(gx10) / T(7);
534 detail::tvec4<T, P> gz10 = floor(gy10) / T(6);
538 detail::tvec4<T, P> gw10 = detail::tvec4<T, P>(0.75) - abs(gx10) - abs(gy10) - abs(gz10);
539 detail::tvec4<T, P> sw10 = step(gw10, detail::tvec4<T, P>(0.0));
543 detail::tvec4<T, P> gx11 = ixy11 / T(7);
544 detail::tvec4<T, P> gy11 = floor(gx11) / T(7);
545 detail::tvec4<T, P> gz11 = floor(gy11) / T(6);
549 detail::tvec4<T, P> gw11 = detail::tvec4<T, P>(0.75) - abs(gx11) - abs(gy11) - abs(gz11);
550 detail::tvec4<T, P> sw11 = step(gw11, detail::tvec4<T, P>(T(0)));
554 detail::tvec4<T, P> g0000(gx00.x, gy00.x, gz00.x, gw00.x);
555 detail::tvec4<T, P> g1000(gx00.y, gy00.y, gz00.y, gw00.y);
556 detail::tvec4<T, P> g0100(gx00.z, gy00.z, gz00.z, gw00.z);
557 detail::tvec4<T, P> g1100(gx00.w, gy00.w, gz00.w, gw00.w);
558 detail::tvec4<T, P> g0010(gx10.x, gy10.x, gz10.x, gw10.x);
559 detail::tvec4<T, P> g1010(gx10.y, gy10.y, gz10.y, gw10.y);
560 detail::tvec4<T, P> g0110(gx10.z, gy10.z, gz10.z, gw10.z);
561 detail::tvec4<T, P> g1110(gx10.w, gy10.w, gz10.w, gw10.w);
562 detail::tvec4<T, P> g0001(gx01.x, gy01.x, gz01.x, gw01.x);
563 detail::tvec4<T, P> g1001(gx01.y, gy01.y, gz01.y, gw01.y);
564 detail::tvec4<T, P> g0101(gx01.z, gy01.z, gz01.z, gw01.z);
565 detail::tvec4<T, P> g1101(gx01.w, gy01.w, gz01.w, gw01.w);
566 detail::tvec4<T, P> g0011(gx11.x, gy11.x, gz11.x, gw11.x);
567 detail::tvec4<T, P> g1011(gx11.y, gy11.y, gz11.y, gw11.y);
568 detail::tvec4<T, P> g0111(gx11.z, gy11.z, gz11.z, gw11.z);
569 detail::tvec4<T, P> g1111(gx11.w, gy11.w, gz11.w, gw11.w);
571 detail::tvec4<T, P> norm00 = detail::taylorInvSqrt(detail::tvec4<T, P>(dot(g0000, g0000), dot(g0100, g0100), dot(g1000, g1000), dot(g1100, g1100)));
577 detail::tvec4<T, P> norm01 = detail::taylorInvSqrt(detail::tvec4<T, P>(dot(g0001, g0001), dot(g0101, g0101), dot(g1001, g1001), dot(g1101, g1101)));
583 detail::tvec4<T, P> norm10 = taylorInvSqrt(detail::tvec4<T, P>(dot(g0010, g0010), dot(g0110, g0110), dot(g1010, g1010), dot(g1110, g1110)));
589 detail::tvec4<T, P> norm11 = taylorInvSqrt(detail::tvec4<T, P>(dot(g0011, g0011), dot(g0111, g0111), dot(g1011, g1011), dot(g1111, g1111)));
596 T n1000 = dot(g1000, detail::tvec4<T, P>(Pf1.x, Pf0.y, Pf0.z, Pf0.w));
597 T n0100 = dot(g0100, detail::tvec4<T, P>(Pf0.x, Pf1.y, Pf0.z, Pf0.w));
598 T n1100 = dot(g1100, detail::tvec4<T, P>(Pf1.x, Pf1.y, Pf0.z, Pf0.w));
599 T n0010 = dot(g0010, detail::tvec4<T, P>(Pf0.x, Pf0.y, Pf1.z, Pf0.w));
600 T n1010 = dot(g1010, detail::tvec4<T, P>(Pf1.x, Pf0.y, Pf1.z, Pf0.w));
601 T n0110 = dot(g0110, detail::tvec4<T, P>(Pf0.x, Pf1.y, Pf1.z, Pf0.w));
602 T n1110 = dot(g1110, detail::tvec4<T, P>(Pf1.x, Pf1.y, Pf1.z, Pf0.w));
603 T n0001 = dot(g0001, detail::tvec4<T, P>(Pf0.x, Pf0.y, Pf0.z, Pf1.w));
604 T n1001 = dot(g1001, detail::tvec4<T, P>(Pf1.x, Pf0.y, Pf0.z, Pf1.w));
605 T n0101 = dot(g0101, detail::tvec4<T, P>(Pf0.x, Pf1.y, Pf0.z, Pf1.w));
606 T n1101 = dot(g1101, detail::tvec4<T, P>(Pf1.x, Pf1.y, Pf0.z, Pf1.w));
607 T n0011 = dot(g0011, detail::tvec4<T, P>(Pf0.x, Pf0.y, Pf1.z, Pf1.w));
608 T n1011 = dot(g1011, detail::tvec4<T, P>(Pf1.x, Pf0.y, Pf1.z, Pf1.w));
609 T n0111 = dot(g0111, detail::tvec4<T, P>(Pf0.x, Pf1.y, Pf1.z, Pf1.w));
612 detail::tvec4<T, P> fade_xyzw = fade(Pf0);
613 detail::tvec4<T, P> n_0w = mix(detail::tvec4<T, P>(n0000, n1000, n0100, n1100), detail::tvec4<T, P>(n0001, n1001, n0101, n1101), fade_xyzw.w);
614 detail::tvec4<T, P> n_1w = mix(detail::tvec4<T, P>(n0010, n1010, n0110, n1110), detail::tvec4<T, P>(n0011, n1011, n0111, n1111), fade_xyzw.w);
615 detail::tvec4<T, P> n_zw = mix(n_0w, n_1w, fade_xyzw.z);
616 detail::tvec2<T, P> n_yzw = mix(detail::tvec2<T, P>(n_zw.x, n_zw.y), detail::tvec2<T, P>(n_zw.z, n_zw.w), fade_xyzw.y);
622 GLM_FUNC_QUALIFIER T simplex(glm::detail::tvec2<T, P> const & v)
624 detail::tvec4<T, P> const C = detail::tvec4<T, P>(
631 detail::tvec2<T, P> i = floor(v + dot(v, detail::tvec2<T, P>(C[1])));
632 detail::tvec2<T, P> x0 = v - i + dot(i, detail::tvec2<T, P>(C[0]));
637 detail::tvec2<T, P> i1 = (x0.x > x0.y) ? detail::tvec2<T, P>(1, 0) : detail::tvec2<T, P>(0, 1);
641 detail::tvec4<T, P> x12 = detail::tvec4<T, P>(x0.x, x0.y, x0.x, x0.y) + detail::tvec4<T, P>(C.x, C.x, C.z, C.z);
642 x12 = detail::tvec4<T, P>(detail::tvec2<T, P>(x12) - i1, x12.z, x12.w);
645 i = mod(i, detail::tvec2<T, P>(289)); // Avoid truncation effects in permutation
646 detail::tvec3<T, P> p = detail::permute(
647 detail::permute(i.y + detail::tvec3<T, P>(T(0), i1.y, T(1)))
648 + i.x + detail::tvec3<T, P>(T(0), i1.x, T(1)));
650 detail::tvec3<T, P> m = max(detail::tvec3<T, P>(0.5) - detail::tvec3<T, P>(
652 dot(detail::tvec2<T, P>(x12.x, x12.y), detail::tvec2<T, P>(x12.x, x12.y)),
653 dot(detail::tvec2<T, P>(x12.z, x12.w), detail::tvec2<T, P>(x12.z, x12.w))), detail::tvec3<T, P>(0));
660 detail::tvec3<T, P> x = static_cast<T>(2) * fract(p * C.w) - T(1);
661 detail::tvec3<T, P> h = abs(x) - T(0.5);
662 detail::tvec3<T, P> ox = floor(x + T(0.5));
663 detail::tvec3<T, P> a0 = x - ox;
670 detail::tvec3<T, P> g;
679 GLM_FUNC_QUALIFIER T simplex(detail::tvec3<T, P> const & v)
681 detail::tvec2<T, P> const C(1.0 / 6.0, 1.0 / 3.0);
682 detail::tvec4<T, P> const D(0.0, 0.5, 1.0, 2.0);
685 detail::tvec3<T, P> i(floor(v + dot(v, detail::tvec3<T, P>(C.y))));
686 detail::tvec3<T, P> x0(v - i + dot(i, detail::tvec3<T, P>(C.x)));
689 detail::tvec3<T, P> g(step(detail::tvec3<T, P>(x0.y, x0.z, x0.x), x0));
690 detail::tvec3<T, P> l(T(1) - g);
691 detail::tvec3<T, P> i1(min(g, detail::tvec3<T, P>(l.z, l.x, l.y)));
692 detail::tvec3<T, P> i2(max(g, detail::tvec3<T, P>(l.z, l.x, l.y)));
698 detail
699 detail::tvec3<T, P> x2(x0 - i2 + C.y); // 2.0*C.x = 1/3 = C.y
700 detail::tvec3<T, P> x3(x0 - D.y); // -1.0+3.0*C.x = -0.5 = -D.y
704 detail::tvec4<T, P> p(detail::permute(detail::permute(detail::permute(
705 i.z + detail::tvec4<T, P>(T(0), i1.z, i2.z, T(1))) +
706 i.y + detail::tvec4<T, P>(T(0), i1.y, i2.y, T(1))) +
707 i.x + detail::tvec4<T, P>(T(0), i1.x, i2.x, T(1))));
712 detail::tvec3<T, P> ns(n_ * detail::tvec3<T, P>(D.w, D.y, D.z) - detail::tvec3<T, P>(D.x, D.z, D.x));
714 detail::tvec4<T, P> j(p - T(49) * floor(p * ns.z * ns.z)); // mod(p,7*7)
716 detail::tvec4<T, P> x_(floor(j * ns.z));
717 detail::tvec4<T, P> y_(floor(j - T(7) * x_)); // mod(j,N)
719 detail::tvec4<T, P> x(x_ * ns.x + ns.y);
720 detail::tvec4<T, P> y(y_ * ns.x + ns.y);
721 detail::tvec4<T, P> h(T(1) - abs(x) - abs(y));
723 detail::tvec4<T, P> b0(x.x, x.y, y.x, y.y);
724 detail::tvec4<T, P> b1(x.z, x.w, y.z, y.w);
728 detail::tvec4<T, P> s0(floor(b0) * T(2) + T(1));
729 detail::tvec4<T, P> s1(floor(b1) * T(2) + T(1));
730 detail::tvec4<T, P> sh(-step(h, detail::tvec4<T, P>(0.0)));
732 detail::tvec4<T, P> a0 = detail::tvec4<T, P>(b0.x, b0.z, b0.y, b0.w) + detail::tvec4<T, P>(s0.x, s0.z, s0.y, s0.w) * detail::tvec4<T, P>(sh.x, sh.x, sh.y, sh.y);
733 detail::tvec4<T, P> a1 = detail::tvec4<T, P>(b1.x, b1.z, b1.y, b1.w) + detail::tvec4<T, P>(s1.x, s1.z, s1.y, s1.w) * detail::tvec4<T, P>(sh.z, sh.z, sh.w, sh.w);
735 detail::tvec3<T, P> p0(a0.x, a0.y, h.x);
736 detail::tvec3<T, P> p1(a0.z, a0.w, h.y);
737 detail::tvec3<T, P> p2(a1.x, a1.y, h.z);
738 detail::tvec3<T, P> p3(a1.z, a1.w, h.w);
741 detail::tvec4<T, P> norm = detail::taylorInvSqrt(detail::tvec4<T, P>(dot(p0, p0), dot(p1, p1), dot(p2, p2), dot(p3, p3)));
748 detail::tvec4<T, P> m = max(T(0.6) - detail::tvec4<T, P>(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), detail::tvec4<T, P>(0));
750 return T(42) * dot(m * m, detail::tvec4<T, P>(dot(p0, x0), dot(p1, x1), dot(p2, x2), dot(p3, x3)));
754 GLM_FUNC_QUALIFIER T simplex(detail::tvec4<T, P> const & v)
756 detail::tvec4<T, P> const C(
766 detail::tvec4<T, P> i = floor(v + dot(v, vec4(F4)));
767 detail::tvec4<T, P> x0 = v - i + dot(i, vec4(C.x));
772 detail::tvec4<T, P> i0;
773 detail::tvec3<T, P> isX = step(detail::tvec3<T, P>(x0.y, x0.z, x0.w), detail::tvec3<T, P>(x0.x));
774 detail::tvec3<T, P> isYZ = step(detail::tvec3<T, P>(x0.z, x0.w, x0.w), detail::tvec3<T, P>(x0.y, x0.y, x0.z));
778 i0 = detail::tvec4<T, P>(isX.x + isX.y + isX.z, T(1) - isX);
781 //i0.zw += 1.0 - detail::tvec2<T, P>(isYZ.x, isYZ.y);
788 detail::tvec4<T, P> i3 = clamp(i0, T(0), T(1));
789 detail::tvec4<T, P> i2 = clamp(i0 - T(1), T(0), T(1));
790 detail::tvec4<T, P> i1 = clamp(i0 - T(2), T(0), T(1));
797 detail::tvec4<T, P> x1 = x0 - i1 + C.x;
798 detail::tvec4<T, P> x2 = x0 - i2 + C.y;
799 detail::tvec4<T, P> x3 = x0 - i3 + C.z;
800 detail::tvec4<T, P> x4 = x0 + C.w;
803 i = mod(i, detail::tvec4<T, P>(289));
804 T j0 = detail::permute(detail::permute(detail::permute(detail::permute(i.w) + i.z) + i.y) + i.x);
805 detail::tvec4<T, P> j1 = detail::permute(detail::permute(detail::permute(detail::permute(
806 i.w + detail::tvec4<T, P>(i1.w, i2.w, i3.w, T(1))) +
807 i.z + detail::tvec4<T, P>(i1.z, i2.z, i3.z, T(1))) +
808 i.y + detail::tvec4<T, P>(i1.y, i2.y, i3.y, T(1))) +
809 i.x + detail::tvec4<T, P>(i1.x, i2.x, i3.x, T(1)));
813 detail::tvec4<T, P> ip = detail::tvec4<T, P>(T(1) / T(294), T(1) / T(49), T(1) / T(7), T(0));
815 detail::tvec4<T, P> p0 = gtc::grad4(j0, ip);
816 detail::tvec4<T, P> p1 = gtc::grad4(j1.x, ip);
817 detail::tvec4<T, P> p2 = gtc::grad4(j1.y, ip);
818 detail::tvec4<T, P> p3 = gtc::grad4(j1.z, ip);
819 detail::tvec4<T, P> p4 = gtc::grad4(j1.w, ip);
822 detail::tvec4<T, P> norm = detail::taylorInvSqrt(detail::tvec4<T, P>(dot(p0, p0), dot(p1, p1), dot(p2, p2), dot(p3, p3)));
827 p4 *= detail::taylorInvSqrt(dot(p4, p4));
830 detail::tvec3<T, P> m0 = max(T(0.6) - detail::tvec3<T, P>(dot(x0, x0), dot(x1, x1), dot(x2, x2)), detail::tvec3<T, P>(0));
831 detail::tvec2<T, P> m1 = max(T(0.6) - detail::tvec2<T, P>(dot(x3, x3), dot(x4, x4) ), detail::tvec2<T, P>(0));
835 (dot(m0 * m0, detail::tvec3<T, P>(dot(p0, x0), dot(p1, x1), dot(p2, x2))) +
836 dot(m1 * m1, detail::tvec2<T, P>(dot(p3, x3), dot(p4, x4))));