1 |
< |
frac(x)=x-floor(x); |
1 |
> |
{ RCSid $Id$ } |
2 |
> |
{ 2-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 |
< |
rand2a(x,y) = 1-2*rand(.69692*x+.35084*y); |
12 |
< |
rand2b(x,y) = 1-2*rand(.05393*x+.96196*y); |
13 |
< |
rand2c(x,y) = 1-2*rand(.04234*x+.46180*y); |
11 |
> |
rand2a(x,y) : 1-2*rand(.69692*x+.35084*y); |
12 |
> |
rand2b(x,y) : 1-2*rand(.05393*x+.96196*y); |
13 |
> |
rand2c(x,y) : 1-2*rand(.04234*x+.46180*y); |
14 |
|
|
15 |
< |
noise2(x,y) = noise_2( floor(x),frac(x),ceil(x), |
13 |
< |
floor(y),frac(y),ceil(y) ); |
14 |
< |
|
15 |
< |
noise_2(xl,xd,xu,yl,yd,yu) = |
15 |
> |
noise_2(xl,xd,xu,yl,yd,yu) : |
16 |
|
hermite( |
17 |
|
hermite(rand2c(xl,yl), |
18 |
|
rand2c(xu,yl), |
29 |
|
(1-xd)*rand2b(xl,yu)+ |
30 |
|
xd*rand2b(xu,yu), |
31 |
|
yd); |
32 |
+ |
|
33 |
+ |
noise2(x,y) : noise_2( floor(x),frac(x),ceil(x), |
34 |
+ |
floor(y),frac(y),ceil(y) ); |