1 |
< |
frac(x)=x-floor(x); |
1 |
> |
{ RCSid $Id$ } |
2 |
> |
{ 3-D Perlin Noise function } |
3 |
|
|
4 |
< |
hermite(p0,p1,r0,r1,t) = p0 * ((2*t-3)*t*t+1) + |
4 |
> |
frac(x):x-floor(x); |
5 |
> |
|
6 |
> |
hermite(p0,p1,r0,r1,t) : p0 * ((2*t-3)*t*t+1) + |
7 |
|
p1 * (-2*t+3)*t*t + |
8 |
|
r0 * (((t-2)*t+1)*t) + |
9 |
|
r1 * ((t-1)*t*t); |
10 |
|
|
11 |
< |
rand3a(x,y,z) = 1-2*rand(.69692*x+.35084*y+.26765*z); |
12 |
< |
rand3b(x,y,z) = 1-2*rand(.05393*x+.96196*y+.28617*z); |
13 |
< |
rand3c(x,y,z) = 1-2*rand(.04234*x+.46180*y+.54550*z); |
14 |
< |
rand3d(x,y,z) = 1-2*rand(.07211*x+.76411*y+.95567*z); |
11 |
> |
rand3a(x,y,z) : 1-2*rand(.69692*x+.35084*y+.26765*z); |
12 |
> |
rand3b(x,y,z) : 1-2*rand(.05393*x+.96196*y+.28617*z); |
13 |
> |
rand3c(x,y,z) : 1-2*rand(.04234*x+.46180*y+.54550*z); |
14 |
> |
rand3d(x,y,z) : 1-2*rand(.07211*x+.76411*y+.95567*z); |
15 |
|
|
16 |
< |
noise3(x,y,z) = noise_3( floor(x),frac(x),ceil(x), |
14 |
< |
floor(y),frac(y),ceil(y), |
15 |
< |
floor(z),frac(z),ceil(z) ); |
16 |
< |
|
17 |
< |
noise_3(xl,xd,xu,yl,yd,yu,zl,zd,zu) = |
16 |
> |
noise_3(xl,xd,xu,yl,yd,yu,zl,zd,zu) : |
17 |
|
hermite( |
18 |
|
hermite( |
19 |
|
hermite(rand3d(xl,yl,zl), |
56 |
|
yd*((1-xd)*rand3c(xl,yu,zu) + |
57 |
|
xd*rand3c(xu,yu,zu)), |
58 |
|
zd); |
59 |
+ |
|
60 |
+ |
|
61 |
+ |
noise3(x,y,z) : noise_3( floor(x),frac(x),ceil(x), |
62 |
+ |
floor(y),frac(y),ceil(y), |
63 |
+ |
floor(z),frac(z),ceil(z) ); |