ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/cal/cal/noise2.cal
Revision: 1.2
Committed: Wed Nov 21 17:45:45 2018 UTC (5 years, 5 months ago) by greg
Branch: MAIN
CVS Tags: rad5R4, rad5R3, HEAD
Changes since 1.1: +12 -9 lines
Log Message:
Minor fixes/improvements

File Contents

# Content
1 { RCSid $Id$ }
2 { 2-D Perlin Noise function }
3
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);
14
15 noise_2(xl,xd,xu,yl,yd,yu) :
16 hermite(
17 hermite(rand2c(xl,yl),
18 rand2c(xu,yl),
19 rand2a(xl,yl),
20 rand2a(xu,yl),
21 xd),
22 hermite(rand2c(xl,yu),
23 rand2c(xu,yu),
24 rand2a(xl,yu),
25 rand2a(xu,yu),
26 xd),
27 (1-xd)*rand2b(xl,yl)+
28 xd*rand2b(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) );