1 |
greg |
1.1 |
{ |
2 |
|
|
Add veiling glare caused by bright sources to an image. |
3 |
|
|
Input is direction and illuminances of sources as may |
4 |
|
|
be determined with the Radiance program, findglare(1). |
5 |
|
|
|
6 |
|
|
N : Number of glaring sources |
7 |
|
|
SDx(i) : x component of normalized direction to source i |
8 |
|
|
SDy(i) : y component of same |
9 |
|
|
SDz(i) : z component of same |
10 |
|
|
I(i) : illuminance (lux) due to i in source's direction |
11 |
|
|
(multiply the luminance by the solid angle) |
12 |
|
|
|
13 |
|
|
An automated way to get this is to send the output of findglare |
14 |
|
|
into tabfunc, i.e.: |
15 |
|
|
|
16 |
|
|
findglare [options] | sed -e '1,/^BEGIN glare source$/d' \ |
17 |
|
|
-e '/^END glare source$/,$d' \ |
18 |
|
|
| rcalc -e '$1=recno;$2=$1;$3=$2;$4=$3;$5=$4*$5' \ |
19 |
|
|
| tabfunc SDx SDy SDz I > glrsrc.cal |
20 |
|
|
|
21 |
|
|
Then, simply define N with "N:I(0)" either with a -e option to |
22 |
|
|
pcomb or as an additional line in glrsrc.cal, i.e.: |
23 |
|
|
|
24 |
|
|
pcomb -f glrsrc.cal -e 'N:I(0)' -f veil.cal orig.pic > veil.pic |
25 |
|
|
} |
26 |
|
|
|
27 |
|
|
bound(a,x,b) : if(a-x, a, if(x-b, b, x)); |
28 |
|
|
Acos(x) : acos(bound(-1,x,1)); |
29 |
|
|
|
30 |
|
|
{ mul(t) : if(.5*PI/180-t, 9.2/.5^2, 9.2/(180/PI)^2/(t*t)); } |
31 |
|
|
|
32 |
|
|
mul(t) : if(1.58724464*PI/180-t, 9.2/((if(t-.00291,t,.00291)*(180/PI))^3.44), |
33 |
|
|
9.2/((180/PI*t)*(1.5+180/PI*t))); |
34 |
|
|
|
35 |
|
|
Dx1 = Dx(1); Dy1 = Dy(1); Dz1 = Dz(1); { minor optimization } |
36 |
|
|
|
37 |
|
|
angle(i) = Acos(SDx(i)*Dx1+SDy(i)*Dy1+SDz(i)*Dz1); |
38 |
|
|
|
39 |
|
|
sum(i) = if(i-.5, mul(angle(i))*I(i)+sum(i-1), 0); |
40 |
|
|
|
41 |
|
|
veil = le(1)/WE * sum(N); |
42 |
|
|
|
43 |
|
|
ro = ri(1) + veil; |
44 |
|
|
go = gi(1) + veil; |
45 |
|
|
bo = bi(1) + veil; |