Blender  V2.93
svm_noise.h
Go to the documentation of this file.
1 /*
2  * Adapted from Open Shading Language with this license:
3  *
4  * Copyright (c) 2009-2010 Sony Pictures Imageworks Inc., et al.
5  * All Rights Reserved.
6  *
7  * Modifications Copyright 2011, Blender Foundation.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions are
11  * met:
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above copyright
15  * notice, this list of conditions and the following disclaimer in the
16  * documentation and/or other materials provided with the distribution.
17  * * Neither the name of Sony Pictures Imageworks nor the names of its
18  * contributors may be used to endorse or promote products derived from
19  * this software without specific prior written permission.
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
34 
35 /* **** Perlin Noise **** */
36 
37 ccl_device float fade(float t)
38 {
39  return t * t * t * (t * (t * 6.0f - 15.0f) + 10.0f);
40 }
41 
42 ccl_device_inline float negate_if(float val, int condition)
43 {
44  return (condition) ? -val : val;
45 }
46 
47 ccl_device float grad1(int hash, float x)
48 {
49  int h = hash & 15;
50  float g = 1 + (h & 7);
51  return negate_if(g, h & 8) * x;
52 }
53 
55 {
56  int X;
57  float fx = floorfrac(x, &X);
58  float u = fade(fx);
59 
60  return mix(grad1(hash_uint(X), fx), grad1(hash_uint(X + 1), fx - 1.0f), u);
61 }
62 
63 /* 2D, 3D, and 4D noise can be accelerated using SSE, so we first check if
64  * SSE is supported, that is, if __KERNEL_SSE2__ is defined. If it is not
65  * supported, we do a standard implementation, but if it is supported, we
66  * do an implementation using SSE intrinsics.
67  */
68 #if !defined(__KERNEL_SSE2__)
69 
70 /* ** Standard Implementation ** */
71 
72 /* Bilinear Interpolation:
73  *
74  * v2 v3
75  * @ + + + + @ y
76  * + + ^
77  * + + |
78  * + + |
79  * @ + + + + @ @------> x
80  * v0 v1
81  *
82  */
83 ccl_device float bi_mix(float v0, float v1, float v2, float v3, float x, float y)
84 {
85  float x1 = 1.0f - x;
86  return (1.0f - y) * (v0 * x1 + v1 * x) + y * (v2 * x1 + v3 * x);
87 }
88 
89 /* Trilinear Interpolation:
90  *
91  * v6 v7
92  * @ + + + + + + @
93  * +\ +\
94  * + \ + \
95  * + \ + \
96  * + \ v4 + \ v5
97  * + @ + + + +++ + @ z
98  * + + + + y ^
99  * v2 @ + +++ + + + @ v3 + \ |
100  * \ + \ + \ |
101  * \ + \ + \|
102  * \ + \ + +---------> x
103  * \+ \+
104  * @ + + + + + + @
105  * v0 v1
106  */
107 ccl_device float tri_mix(float v0,
108  float v1,
109  float v2,
110  float v3,
111  float v4,
112  float v5,
113  float v6,
114  float v7,
115  float x,
116  float y,
117  float z)
118 {
119  float x1 = 1.0f - x;
120  float y1 = 1.0f - y;
121  float z1 = 1.0f - z;
122  return z1 * (y1 * (v0 * x1 + v1 * x) + y * (v2 * x1 + v3 * x)) +
123  z * (y1 * (v4 * x1 + v5 * x) + y * (v6 * x1 + v7 * x));
124 }
125 
126 ccl_device float quad_mix(float v0,
127  float v1,
128  float v2,
129  float v3,
130  float v4,
131  float v5,
132  float v6,
133  float v7,
134  float v8,
135  float v9,
136  float v10,
137  float v11,
138  float v12,
139  float v13,
140  float v14,
141  float v15,
142  float x,
143  float y,
144  float z,
145  float w)
146 {
147  return mix(tri_mix(v0, v1, v2, v3, v4, v5, v6, v7, x, y, z),
148  tri_mix(v8, v9, v10, v11, v12, v13, v14, v15, x, y, z),
149  w);
150 }
151 
152 ccl_device float grad2(int hash, float x, float y)
153 {
154  int h = hash & 7;
155  float u = h < 4 ? x : y;
156  float v = 2.0f * (h < 4 ? y : x);
157  return negate_if(u, h & 1) + negate_if(v, h & 2);
158 }
159 
160 ccl_device float grad3(int hash, float x, float y, float z)
161 {
162  int h = hash & 15;
163  float u = h < 8 ? x : y;
164  float vt = ((h == 12) || (h == 14)) ? x : z;
165  float v = h < 4 ? y : vt;
166  return negate_if(u, h & 1) + negate_if(v, h & 2);
167 }
168 
169 ccl_device float grad4(int hash, float x, float y, float z, float w)
170 {
171  int h = hash & 31;
172  float u = h < 24 ? x : y;
173  float v = h < 16 ? y : z;
174  float s = h < 8 ? z : w;
175  return negate_if(u, h & 1) + negate_if(v, h & 2) + negate_if(s, h & 4);
176 }
177 
179 {
180  int X;
181  int Y;
182 
183  float fx = floorfrac(x, &X);
184  float fy = floorfrac(y, &Y);
185 
186  float u = fade(fx);
187  float v = fade(fy);
188 
189  float r = bi_mix(grad2(hash_uint2(X, Y), fx, fy),
190  grad2(hash_uint2(X + 1, Y), fx - 1.0f, fy),
191  grad2(hash_uint2(X, Y + 1), fx, fy - 1.0f),
192  grad2(hash_uint2(X + 1, Y + 1), fx - 1.0f, fy - 1.0f),
193  u,
194  v);
195 
196  return r;
197 }
198 
199 ccl_device_noinline_cpu float perlin_3d(float x, float y, float z)
200 {
201  int X;
202  int Y;
203  int Z;
204 
205  float fx = floorfrac(x, &X);
206  float fy = floorfrac(y, &Y);
207  float fz = floorfrac(z, &Z);
208 
209  float u = fade(fx);
210  float v = fade(fy);
211  float w = fade(fz);
212 
213  float r = tri_mix(grad3(hash_uint3(X, Y, Z), fx, fy, fz),
214  grad3(hash_uint3(X + 1, Y, Z), fx - 1.0f, fy, fz),
215  grad3(hash_uint3(X, Y + 1, Z), fx, fy - 1.0f, fz),
216  grad3(hash_uint3(X + 1, Y + 1, Z), fx - 1.0f, fy - 1.0f, fz),
217  grad3(hash_uint3(X, Y, Z + 1), fx, fy, fz - 1.0f),
218  grad3(hash_uint3(X + 1, Y, Z + 1), fx - 1.0f, fy, fz - 1.0f),
219  grad3(hash_uint3(X, Y + 1, Z + 1), fx, fy - 1.0f, fz - 1.0f),
220  grad3(hash_uint3(X + 1, Y + 1, Z + 1), fx - 1.0f, fy - 1.0f, fz - 1.0f),
221  u,
222  v,
223  w);
224  return r;
225 }
226 
227 ccl_device_noinline_cpu float perlin_4d(float x, float y, float z, float w)
228 {
229  int X;
230  int Y;
231  int Z;
232  int W;
233 
234  float fx = floorfrac(x, &X);
235  float fy = floorfrac(y, &Y);
236  float fz = floorfrac(z, &Z);
237  float fw = floorfrac(w, &W);
238 
239  float u = fade(fx);
240  float v = fade(fy);
241  float t = fade(fz);
242  float s = fade(fw);
243 
244  float r = quad_mix(
245  grad4(hash_uint4(X, Y, Z, W), fx, fy, fz, fw),
246  grad4(hash_uint4(X + 1, Y, Z, W), fx - 1.0f, fy, fz, fw),
247  grad4(hash_uint4(X, Y + 1, Z, W), fx, fy - 1.0f, fz, fw),
248  grad4(hash_uint4(X + 1, Y + 1, Z, W), fx - 1.0f, fy - 1.0f, fz, fw),
249  grad4(hash_uint4(X, Y, Z + 1, W), fx, fy, fz - 1.0f, fw),
250  grad4(hash_uint4(X + 1, Y, Z + 1, W), fx - 1.0f, fy, fz - 1.0f, fw),
251  grad4(hash_uint4(X, Y + 1, Z + 1, W), fx, fy - 1.0f, fz - 1.0f, fw),
252  grad4(hash_uint4(X + 1, Y + 1, Z + 1, W), fx - 1.0f, fy - 1.0f, fz - 1.0f, fw),
253  grad4(hash_uint4(X, Y, Z, W + 1), fx, fy, fz, fw - 1.0f),
254  grad4(hash_uint4(X + 1, Y, Z, W + 1), fx - 1.0f, fy, fz, fw - 1.0f),
255  grad4(hash_uint4(X, Y + 1, Z, W + 1), fx, fy - 1.0f, fz, fw - 1.0f),
256  grad4(hash_uint4(X + 1, Y + 1, Z, W + 1), fx - 1.0f, fy - 1.0f, fz, fw - 1.0f),
257  grad4(hash_uint4(X, Y, Z + 1, W + 1), fx, fy, fz - 1.0f, fw - 1.0f),
258  grad4(hash_uint4(X + 1, Y, Z + 1, W + 1), fx - 1.0f, fy, fz - 1.0f, fw - 1.0f),
259  grad4(hash_uint4(X, Y + 1, Z + 1, W + 1), fx, fy - 1.0f, fz - 1.0f, fw - 1.0f),
260  grad4(hash_uint4(X + 1, Y + 1, Z + 1, W + 1), fx - 1.0f, fy - 1.0f, fz - 1.0f, fw - 1.0f),
261  u,
262  v,
263  t,
264  s);
265 
266  return r;
267 }
268 
269 #else /* SSE is supported. */
270 
271 /* ** SSE Implementation ** */
272 
273 /* SSE Bilinear Interpolation:
274  *
275  * The function takes two ssef inputs:
276  * - p : Contains the values at the points (v0, v1, v2, v3).
277  * - f : Contains the values (x, y, _, _). The third and fourth values are unused.
278  *
279  * The interpolation is done in two steps:
280  * 1. Interpolate (v0, v1) and (v2, v3) along the x axis to get g (g0, g1).
281  * (v2, v3) is generated by moving v2 and v3 to the first and second
282  * places of the ssef using the shuffle mask <2, 3, 2, 3>. The third and
283  * fourth values are unused.
284  * 2. Interpolate g0 and g1 along the y axis to get the final value.
285  * g1 is generated by populating an ssef with the second value of g.
286  * Only the first value is important in the final ssef.
287  *
288  * v1 v3 g1
289  * @ + + + + @ @ y
290  * + + (1) + (2) ^
291  * + + ---> + ---> final |
292  * + + + |
293  * @ + + + + @ @ @------> x
294  * v0 v2 g0
295  *
296  */
297 ccl_device_inline ssef bi_mix(ssef p, ssef f)
298 {
299  ssef g = mix(p, shuffle<2, 3, 2, 3>(p), shuffle<0>(f));
300  return mix(g, shuffle<1>(g), shuffle<1>(f));
301 }
302 
303 ccl_device_inline ssef fade(const ssef &t)
304 {
305  ssef a = madd(t, 6.0f, -15.0f);
306  ssef b = madd(t, a, 10.0f);
307  return (t * t) * (t * b);
308 }
309 
310 /* Negate val if the nth bit of h is 1. */
311 # define negate_if_nth_bit(val, h, n) ((val) ^ cast(((h) & (1 << (n))) << (31 - (n))))
312 
313 ccl_device_inline ssef grad(const ssei &hash, const ssef &x, const ssef &y)
314 {
315  ssei h = hash & 7;
316  ssef u = select(h < 4, x, y);
317  ssef v = 2.0f * select(h < 4, y, x);
318  return negate_if_nth_bit(u, h, 0) + negate_if_nth_bit(v, h, 1);
319 }
320 
321 /* We use SSE to compute and interpolate 4 gradients at once:
322  *
323  * Point Offset from v0
324  * v0 (0, 0)
325  * v1 (0, 1)
326  * v2 (1, 0) (0, 1, 0, 1) = shuffle<0, 2, 0, 2>(shuffle<1, 1, 1, 1>(V, V + 1))
327  * v3 (1, 1) ^
328  * | |__________| (0, 0, 1, 1) = shuffle<0, 0, 0, 0>(V, V + 1)
329  * | ^
330  * |__________________________|
331  *
332  */
333 ccl_device_noinline float perlin_2d(float x, float y)
334 {
335  ssei XY;
336  ssef fxy = floorfrac(ssef(x, y, 0.0f, 0.0f), &XY);
337  ssef uv = fade(fxy);
338 
339  ssei XY1 = XY + 1;
340  ssei X = shuffle<0, 0, 0, 0>(XY, XY1);
341  ssei Y = shuffle<0, 2, 0, 2>(shuffle<1, 1, 1, 1>(XY, XY1));
342 
343  ssei h = hash_ssei2(X, Y);
344 
345  ssef fxy1 = fxy - 1.0f;
346  ssef fx = shuffle<0, 0, 0, 0>(fxy, fxy1);
347  ssef fy = shuffle<0, 2, 0, 2>(shuffle<1, 1, 1, 1>(fxy, fxy1));
348 
349  ssef g = grad(h, fx, fy);
350 
351  return extract<0>(bi_mix(g, uv));
352 }
353 
354 /* SSE Trilinear Interpolation:
355  *
356  * The function takes three ssef inputs:
357  * - p : Contains the values at the points (v0, v1, v2, v3).
358  * - q : Contains the values at the points (v4, v5, v6, v7).
359  * - f : Contains the values (x, y, z, _). The fourth value is unused.
360  *
361  * The interpolation is done in three steps:
362  * 1. Interpolate p and q along the x axis to get s (s0, s1, s2, s3).
363  * 2. Interpolate (s0, s1) and (s2, s3) along the y axis to get g (g0, g1).
364  * (s2, s3) is generated by moving v2 and v3 to the first and second
365  * places of the ssef using the shuffle mask <2, 3, 2, 3>. The third and
366  * fourth values are unused.
367  * 3. Interpolate g0 and g1 along the z axis to get the final value.
368  * g1 is generated by populating an ssef with the second value of g.
369  * Only the first value is important in the final ssef.
370  *
371  * v3 v7
372  * @ + + + + + + @ s3 @
373  * +\ +\ +\
374  * + \ + \ + \
375  * + \ + \ + \ g1
376  * + \ v1 + \ v5 + \ s1 @
377  * + @ + + + +++ + @ + @ + z
378  * + + + + (1) + + (2) + (3) y ^
379  * v2 @ + +++ + + + @ v6 + ---> s2 @ + ---> + ---> final \ |
380  * \ + \ + \ + + \ |
381  * \ + \ + \ + + \|
382  * \ + \ + \ + @ +---------> x
383  * \+ \+ \+ g0
384  * @ + + + + + + @ @
385  * v0 v4 s0
386  */
387 ccl_device_inline ssef tri_mix(ssef p, ssef q, ssef f)
388 {
389  ssef s = mix(p, q, shuffle<0>(f));
390  ssef g = mix(s, shuffle<2, 3, 2, 3>(s), shuffle<1>(f));
391  return mix(g, shuffle<1>(g), shuffle<2>(f));
392 }
393 
394 /* 3D and 4D noise can be accelerated using AVX, so we first check if AVX
395  * is supported, that is, if __KERNEL_AVX__ is defined. If it is not
396  * supported, we do an SSE implementation, but if it is supported,
397  * we do an implementation using AVX intrinsics.
398  */
399 # if !defined(__KERNEL_AVX__)
400 
401 ccl_device_inline ssef grad(const ssei &hash, const ssef &x, const ssef &y, const ssef &z)
402 {
403  ssei h = hash & 15;
404  ssef u = select(h < 8, x, y);
405  ssef vt = select((h == 12) | (h == 14), x, z);
406  ssef v = select(h < 4, y, vt);
407  return negate_if_nth_bit(u, h, 0) + negate_if_nth_bit(v, h, 1);
408 }
409 
411 grad(const ssei &hash, const ssef &x, const ssef &y, const ssef &z, const ssef &w)
412 {
413  ssei h = hash & 31;
414  ssef u = select(h < 24, x, y);
415  ssef v = select(h < 16, y, z);
416  ssef s = select(h < 8, z, w);
417  return negate_if_nth_bit(u, h, 0) + negate_if_nth_bit(v, h, 1) + negate_if_nth_bit(s, h, 2);
418 }
419 
420 /* SSE Quadrilinear Interpolation:
421  *
422  * Quadrilinear interpolation is as simple as a linear interpolation
423  * between two trilinear interpolations.
424  *
425  */
426 ccl_device_inline ssef quad_mix(ssef p, ssef q, ssef r, ssef s, ssef f)
427 {
428  return mix(tri_mix(p, q, f), tri_mix(r, s, f), shuffle<3>(f));
429 }
430 
431 /* We use SSE to compute and interpolate 4 gradients at once. Since we have 8
432  * gradients in 3D, we need to compute two sets of gradients at the points:
433  *
434  * Point Offset from v0
435  * v0 (0, 0, 0)
436  * v1 (0, 0, 1)
437  * v2 (0, 1, 0) (0, 1, 0, 1) = shuffle<0, 2, 0, 2>(shuffle<2, 2, 2, 2>(V, V + 1))
438  * v3 (0, 1, 1) ^
439  * | |__________| (0, 0, 1, 1) = shuffle<1, 1, 1, 1>(V, V + 1)
440  * | ^
441  * |__________________________|
442  *
443  * Point Offset from v0
444  * v4 (1, 0, 0)
445  * v5 (1, 0, 1)
446  * v6 (1, 1, 0)
447  * v7 (1, 1, 1)
448  *
449  */
450 ccl_device_noinline float perlin_3d(float x, float y, float z)
451 {
452  ssei XYZ;
453  ssef fxyz = floorfrac(ssef(x, y, z, 0.0f), &XYZ);
454  ssef uvw = fade(fxyz);
455 
456  ssei XYZ1 = XYZ + 1;
457  ssei Y = shuffle<1, 1, 1, 1>(XYZ, XYZ1);
458  ssei Z = shuffle<0, 2, 0, 2>(shuffle<2, 2, 2, 2>(XYZ, XYZ1));
459 
460  ssei h1 = hash_ssei3(shuffle<0>(XYZ), Y, Z);
461  ssei h2 = hash_ssei3(shuffle<0>(XYZ1), Y, Z);
462 
463  ssef fxyz1 = fxyz - 1.0f;
464  ssef fy = shuffle<1, 1, 1, 1>(fxyz, fxyz1);
465  ssef fz = shuffle<0, 2, 0, 2>(shuffle<2, 2, 2, 2>(fxyz, fxyz1));
466 
467  ssef g1 = grad(h1, shuffle<0>(fxyz), fy, fz);
468  ssef g2 = grad(h2, shuffle<0>(fxyz1), fy, fz);
469 
470  return extract<0>(tri_mix(g1, g2, uvw));
471 }
472 
473 /* We use SSE to compute and interpolate 4 gradients at once. Since we have 16
474  * gradients in 4D, we need to compute four sets of gradients at the points:
475  *
476  * Point Offset from v0
477  * v0 (0, 0, 0, 0)
478  * v1 (0, 0, 1, 0)
479  * v2 (0, 1, 0, 0) (0, 1, 0, 1) = shuffle<0, 2, 0, 2>(shuffle<2, 2, 2, 2>(V, V + 1))
480  * v3 (0, 1, 1, 0) ^
481  * | |________| (0, 0, 1, 1) = shuffle<1, 1, 1, 1>(V, V + 1)
482  * | ^
483  * |_______________________|
484  *
485  * Point Offset from v0
486  * v4 (1, 0, 0, 0)
487  * v5 (1, 0, 1, 0)
488  * v6 (1, 1, 0, 0)
489  * v7 (1, 1, 1, 0)
490  *
491  * Point Offset from v0
492  * v8 (0, 0, 0, 1)
493  * v9 (0, 0, 1, 1)
494  * v10 (0, 1, 0, 1)
495  * v11 (0, 1, 1, 1)
496  *
497  * Point Offset from v0
498  * v12 (1, 0, 0, 1)
499  * v13 (1, 0, 1, 1)
500  * v14 (1, 1, 0, 1)
501  * v15 (1, 1, 1, 1)
502  *
503  */
504 ccl_device_noinline float perlin_4d(float x, float y, float z, float w)
505 {
506  ssei XYZW;
507  ssef fxyzw = floorfrac(ssef(x, y, z, w), &XYZW);
508  ssef uvws = fade(fxyzw);
509 
510  ssei XYZW1 = XYZW + 1;
511  ssei Y = shuffle<1, 1, 1, 1>(XYZW, XYZW1);
512  ssei Z = shuffle<0, 2, 0, 2>(shuffle<2, 2, 2, 2>(XYZW, XYZW1));
513 
514  ssei h1 = hash_ssei4(shuffle<0>(XYZW), Y, Z, shuffle<3>(XYZW));
515  ssei h2 = hash_ssei4(shuffle<0>(XYZW1), Y, Z, shuffle<3>(XYZW));
516 
517  ssei h3 = hash_ssei4(shuffle<0>(XYZW), Y, Z, shuffle<3>(XYZW1));
518  ssei h4 = hash_ssei4(shuffle<0>(XYZW1), Y, Z, shuffle<3>(XYZW1));
519 
520  ssef fxyzw1 = fxyzw - 1.0f;
521  ssef fy = shuffle<1, 1, 1, 1>(fxyzw, fxyzw1);
522  ssef fz = shuffle<0, 2, 0, 2>(shuffle<2, 2, 2, 2>(fxyzw, fxyzw1));
523 
524  ssef g1 = grad(h1, shuffle<0>(fxyzw), fy, fz, shuffle<3>(fxyzw));
525  ssef g2 = grad(h2, shuffle<0>(fxyzw1), fy, fz, shuffle<3>(fxyzw));
526 
527  ssef g3 = grad(h3, shuffle<0>(fxyzw), fy, fz, shuffle<3>(fxyzw1));
528  ssef g4 = grad(h4, shuffle<0>(fxyzw1), fy, fz, shuffle<3>(fxyzw1));
529 
530  return extract<0>(quad_mix(g1, g2, g3, g4, uvws));
531 }
532 
533 # else /* AVX is supported. */
534 
535 /* AVX Implementation */
536 
537 ccl_device_inline avxf grad(const avxi &hash, const avxf &x, const avxf &y, const avxf &z)
538 {
539  avxi h = hash & 15;
540  avxf u = select(h < 8, x, y);
541  avxf vt = select((h == 12) | (h == 14), x, z);
542  avxf v = select(h < 4, y, vt);
543  return negate_if_nth_bit(u, h, 0) + negate_if_nth_bit(v, h, 1);
544 }
545 
547 grad(const avxi &hash, const avxf &x, const avxf &y, const avxf &z, const avxf &w)
548 {
549  avxi h = hash & 31;
550  avxf u = select(h < 24, x, y);
551  avxf v = select(h < 16, y, z);
552  avxf s = select(h < 8, z, w);
553  return negate_if_nth_bit(u, h, 0) + negate_if_nth_bit(v, h, 1) + negate_if_nth_bit(s, h, 2);
554 }
555 
556 /* SSE Quadrilinear Interpolation:
557  *
558  * The interpolation is done in two steps:
559  * 1. Interpolate p and q along the w axis to get s.
560  * 2. Trilinearly interpolate (s0, s1, s2, s3) and (s4, s5, s6, s7) to get the final
561  * value. (s0, s1, s2, s3) and (s4, s5, s6, s7) are generated by extracting the
562  * low and high ssef from s.
563  *
564  */
565 ccl_device_inline ssef quad_mix(avxf p, avxf q, ssef f)
566 {
567  ssef fv = shuffle<3>(f);
568  avxf s = mix(p, q, avxf(fv, fv));
569  return tri_mix(low(s), high(s), f);
570 }
571 
572 /* We use AVX to compute and interpolate 8 gradients at once.
573  *
574  * Point Offset from v0
575  * v0 (0, 0, 0)
576  * v1 (0, 0, 1) The full AVX type is computed by inserting the following
577  * v2 (0, 1, 0) SSE types into both the low and high parts of the AVX.
578  * v3 (0, 1, 1)
579  * v4 (1, 0, 0)
580  * v5 (1, 0, 1) (0, 1, 0, 1) = shuffle<0, 2, 0, 2>(shuffle<2, 2, 2, 2>(V, V + 1))
581  * v6 (1, 1, 0) ^
582  * v7 (1, 1, 1) |
583  * | |__________| (0, 0, 1, 1) = shuffle<1, 1, 1, 1>(V, V + 1)
584  * | ^
585  * |__________________________|
586  *
587  */
588 ccl_device_noinline float perlin_3d(float x, float y, float z)
589 {
590  ssei XYZ;
591  ssef fxyz = floorfrac(ssef(x, y, z, 0.0f), &XYZ);
592  ssef uvw = fade(fxyz);
593 
594  ssei XYZ1 = XYZ + 1;
595  ssei X = shuffle<0>(XYZ);
596  ssei X1 = shuffle<0>(XYZ1);
597  ssei Y = shuffle<1, 1, 1, 1>(XYZ, XYZ1);
598  ssei Z = shuffle<0, 2, 0, 2>(shuffle<2, 2, 2, 2>(XYZ, XYZ1));
599 
600  avxi h = hash_avxi3(avxi(X, X1), avxi(Y, Y), avxi(Z, Z));
601 
602  ssef fxyz1 = fxyz - 1.0f;
603  ssef fx = shuffle<0>(fxyz);
604  ssef fx1 = shuffle<0>(fxyz1);
605  ssef fy = shuffle<1, 1, 1, 1>(fxyz, fxyz1);
606  ssef fz = shuffle<0, 2, 0, 2>(shuffle<2, 2, 2, 2>(fxyz, fxyz1));
607 
608  avxf g = grad(h, avxf(fx, fx1), avxf(fy, fy), avxf(fz, fz));
609 
610  return extract<0>(tri_mix(low(g), high(g), uvw));
611 }
612 
613 /* We use AVX to compute and interpolate 8 gradients at once. Since we have 16
614  * gradients in 4D, we need to compute two sets of gradients at the points:
615  *
616  * Point Offset from v0
617  * v0 (0, 0, 0, 0)
618  * v1 (0, 0, 1, 0) The full AVX type is computed by inserting the following
619  * v2 (0, 1, 0, 0) SSE types into both the low and high parts of the AVX.
620  * v3 (0, 1, 1, 0)
621  * v4 (1, 0, 0, 0)
622  * v5 (1, 0, 1, 0) (0, 1, 0, 1) = shuffle<0, 2, 0, 2>(shuffle<2, 2, 2, 2>(V, V + 1))
623  * v6 (1, 1, 0, 0) ^
624  * v7 (1, 1, 1, 0) |
625  * | |________| (0, 0, 1, 1) = shuffle<1, 1, 1, 1>(V, V + 1)
626  * | ^
627  * |_______________________|
628  *
629  * Point Offset from v0
630  * v8 (0, 0, 0, 1)
631  * v9 (0, 0, 1, 1)
632  * v10 (0, 1, 0, 1)
633  * v11 (0, 1, 1, 1)
634  * v12 (1, 0, 0, 1)
635  * v13 (1, 0, 1, 1)
636  * v14 (1, 1, 0, 1)
637  * v15 (1, 1, 1, 1)
638  *
639  */
640 ccl_device_noinline float perlin_4d(float x, float y, float z, float w)
641 {
642  ssei XYZW;
643  ssef fxyzw = floorfrac(ssef(x, y, z, w), &XYZW);
644  ssef uvws = fade(fxyzw);
645 
646  ssei XYZW1 = XYZW + 1;
647  ssei X = shuffle<0>(XYZW);
648  ssei X1 = shuffle<0>(XYZW1);
649  ssei Y = shuffle<1, 1, 1, 1>(XYZW, XYZW1);
650  ssei Z = shuffle<0, 2, 0, 2>(shuffle<2, 2, 2, 2>(XYZW, XYZW1));
651  ssei W = shuffle<3>(XYZW);
652  ssei W1 = shuffle<3>(XYZW1);
653 
654  avxi h1 = hash_avxi4(avxi(X, X1), avxi(Y, Y), avxi(Z, Z), avxi(W, W));
655  avxi h2 = hash_avxi4(avxi(X, X1), avxi(Y, Y), avxi(Z, Z), avxi(W1, W1));
656 
657  ssef fxyzw1 = fxyzw - 1.0f;
658  ssef fx = shuffle<0>(fxyzw);
659  ssef fx1 = shuffle<0>(fxyzw1);
660  ssef fy = shuffle<1, 1, 1, 1>(fxyzw, fxyzw1);
661  ssef fz = shuffle<0, 2, 0, 2>(shuffle<2, 2, 2, 2>(fxyzw, fxyzw1));
662  ssef fw = shuffle<3>(fxyzw);
663  ssef fw1 = shuffle<3>(fxyzw1);
664 
665  avxf g1 = grad(h1, avxf(fx, fx1), avxf(fy, fy), avxf(fz, fz), avxf(fw, fw));
666  avxf g2 = grad(h2, avxf(fx, fx1), avxf(fy, fy), avxf(fz, fz), avxf(fw1, fw1));
667 
668  return extract<0>(quad_mix(g1, g2, uvws));
669 }
670 # endif
671 
672 # undef negate_if_nth_bit
673 
674 #endif
675 
676 /* Remap the output of noise to a predictable range [-1, 1].
677  * The scale values were computed experimentally by the OSL developers.
678  */
679 
681 {
682  return 0.2500f * result;
683 }
684 
686 {
687  return 0.6616f * result;
688 }
689 
691 {
692  return 0.9820f * result;
693 }
694 
696 {
697  return 0.8344f * result;
698 }
699 
700 /* Safe Signed And Unsigned Noise */
701 
703 {
705 }
706 
708 {
709  return 0.5f * snoise_1d(p) + 0.5f;
710 }
711 
713 {
714  return noise_scale2(ensure_finite(perlin_2d(p.x, p.y)));
715 }
716 
718 {
719  return 0.5f * snoise_2d(p) + 0.5f;
720 }
721 
723 {
724  return noise_scale3(ensure_finite(perlin_3d(p.x, p.y, p.z)));
725 }
726 
728 {
729  return 0.5f * snoise_3d(p) + 0.5f;
730 }
731 
733 {
734  return noise_scale4(ensure_finite(perlin_4d(p.x, p.y, p.z, p.w)));
735 }
736 
738 {
739  return 0.5f * snoise_4d(p) + 0.5f;
740 }
741 
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble z
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble y1
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble GLdouble r _GL_VOID_RET _GL_VOID GLfloat GLfloat r _GL_VOID_RET _GL_VOID GLint GLint r _GL_VOID_RET _GL_VOID GLshort GLshort r _GL_VOID_RET _GL_VOID GLdouble GLdouble r
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble t
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble v1
#define X
Definition: GeomUtils.cpp:213
#define Z
Definition: GeomUtils.cpp:215
#define Y
Definition: GeomUtils.cpp:214
Group RGB to Bright Vector Camera Vector Combine Material Light Line Style Layer Add Ambient Diffuse Glossy Refraction Transparent Toon Principled Hair Volume Principled Light Particle Volume Image Sky Noise Wave Voronoi Brick Texture Vector Combine Vertex Separate XYZ
#define X1
Definition: RandGen.cpp:34
ATTR_WARN_UNUSED_RESULT const BMVert * v2
ATTR_WARN_UNUSED_RESULT const BMVert * v
#define XY(_x, _y)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition: btQuadWord.h:119
#define ccl_device
#define ccl_device_noinline_cpu
#define ccl_device_inline
#define ccl_device_noinline
#define CCL_NAMESPACE_END
static unsigned a[3]
Definition: RandGen.cpp:92
#define hash
Definition: noise.c:169
BLI_INLINE float grad(int hash_val, float x, float y, float z)
Definition: noise.c:286
Definition: util_avxf.h:24
Definition: util_avxi.h:24
float z
Definition: sky_float3.h:35
float y
Definition: sky_float3.h:35
float x
Definition: sky_float3.h:35
ccl_device float grad4(int hash, float x, float y, float z, float w)
Definition: svm_noise.h:169
ccl_device float quad_mix(float v0, float v1, float v2, float v3, float v4, float v5, float v6, float v7, float v8, float v9, float v10, float v11, float v12, float v13, float v14, float v15, float x, float y, float z, float w)
Definition: svm_noise.h:126
ccl_device_inline float snoise_1d(float p)
Definition: svm_noise.h:702
ccl_device float grad3(int hash, float x, float y, float z)
Definition: svm_noise.h:160
ccl_device_noinline_cpu float perlin_2d(float x, float y)
Definition: svm_noise.h:178
ccl_device_inline float noise_scale4(float result)
Definition: svm_noise.h:695
ccl_device float bi_mix(float v0, float v1, float v2, float v3, float x, float y)
Definition: svm_noise.h:83
ccl_device_inline float noise_2d(float2 p)
Definition: svm_noise.h:717
ccl_device_inline float snoise_2d(float2 p)
Definition: svm_noise.h:712
ccl_device float tri_mix(float v0, float v1, float v2, float v3, float v4, float v5, float v6, float v7, float x, float y, float z)
Definition: svm_noise.h:107
ccl_device_inline float snoise_3d(float3 p)
Definition: svm_noise.h:722
ccl_device_inline float snoise_4d(float4 p)
Definition: svm_noise.h:732
ccl_device_inline float noise_3d(float3 p)
Definition: svm_noise.h:727
ccl_device_inline float noise_4d(float4 p)
Definition: svm_noise.h:737
ccl_device_inline float noise_scale3(float result)
Definition: svm_noise.h:690
ccl_device_inline float noise_scale2(float result)
Definition: svm_noise.h:685
CCL_NAMESPACE_BEGIN ccl_device float fade(float t)
Definition: svm_noise.h:37
ccl_device float grad2(int hash, float x, float y)
Definition: svm_noise.h:152
ccl_device_inline float noise_1d(float p)
Definition: svm_noise.h:707
ccl_device_inline float negate_if(float val, int condition)
Definition: svm_noise.h:42
ccl_device_noinline_cpu float perlin_4d(float x, float y, float z, float w)
Definition: svm_noise.h:227
ccl_device float grad1(int hash, float x)
Definition: svm_noise.h:47
ccl_device_inline float noise_scale1(float result)
Definition: svm_noise.h:680
ccl_device_noinline_cpu float perlin_1d(float x)
Definition: svm_noise.h:54
ccl_device_noinline_cpu float perlin_3d(float x, float y, float z)
Definition: svm_noise.h:199
__forceinline const avxb select(const avxb &m, const avxb &t, const avxb &f)
Definition: util_avxb.h:167
__forceinline const avxf madd(const avxf &a, const avxf &b, const avxf &c)
Ternary Operators.
Definition: util_avxf.h:334
__forceinline ssef low(const avxf &a)
Definition: util_avxf.h:277
__forceinline ssef high(const avxf &a)
Definition: util_avxf.h:281
__forceinline float extract< 0 >(const avxf &a)
Definition: util_avxf.h:272
ccl_device_inline uint hash_uint2(uint kx, uint ky)
Definition: util_hash.h:83
ccl_device_inline uint hash_uint3(uint kx, uint ky, uint kz)
Definition: util_hash.h:95
ccl_device_inline uint hash_uint4(uint kx, uint ky, uint kz, uint kw)
Definition: util_hash.h:108
ccl_device_inline uint hash_uint(uint kx)
Definition: util_hash.h:72
#define mix(a, b, c)
Definition: util_hash.h:30
ccl_device_inline float ensure_finite(float v)
Definition: util_math.h:277
ccl_device_inline float floorfrac(float x, int *i)
Definition: util_math.h:336