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