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