1 |
{ |
2 |
Compute fractal clouds over image |
3 |
|
4 |
Greg Ward 11/1/95 |
5 |
|
6 |
Needs also noise2.cal |
7 |
|
8 |
Usage: |
9 |
pcomb -f noise2.cal -f clouds.cal planet.pic > cloudy.pic |
10 |
|
11 |
Typically, this will be used to add clouds to Earth.pic or |
12 |
bigEarth.pic in the standard library distribution. |
13 |
} |
14 |
|
15 |
{ Modify the following two constants to your liking: } |
16 |
|
17 |
cover_frac : 0.65; { average cloud cover (non-clear fraction) } |
18 |
|
19 |
cloud_refl : 0.7; { average cloud reflectance (always white) } |
20 |
|
21 |
{ Leave the rest alone. } |
22 |
|
23 |
PI : 3.14159265358979323846; |
24 |
|
25 |
clouds(u,v,s) = if(s-.5, noise2(sin(2*PI/xmax*x)+13.5,sin(2*PI/ymax*y)-10.3), |
26 |
noise2(u/s,v/s)*s + clouds(u,v,2*s)); |
27 |
|
28 |
minres : if(xmax-ymax, ymax, xmax); |
29 |
|
30 |
clamp(x) : if(x, if(x-1, 1, x), 0); |
31 |
|
32 |
coef = clamp( 1 + |
33 |
(.5/sqrt(cover_frac)) * (clouds(x/minres, y/minres, 10/minres) - 1) |
34 |
) ; |
35 |
|
36 |
cv = coef * cloud_refl; |
37 |
pv = 1 - coef; |
38 |
|
39 |
ro = cv + pv*ri(1); |
40 |
go = cv + pv*gi(1); |
41 |
bo = cv + pv*bi(1); |