1 |
greg |
2.1 |
#!/bin/csh -f |
2 |
|
|
# RCSid $Id$ |
3 |
|
|
# |
4 |
|
|
# Convert Optics 5 output to correct Radiance input |
5 |
|
|
# |
6 |
|
|
if ($#argv < 1) then |
7 |
|
|
echo "Usage: $0 optics.mat .." |
8 |
|
|
exit 1 |
9 |
|
|
endif |
10 |
|
|
cat > /tmp/opt.fmt << '_EOF_' |
11 |
|
|
void glass $(name)_glass |
12 |
|
|
0 |
13 |
|
|
0 |
14 |
|
|
3 ${Rtn} ${Gtn} ${Btn} |
15 |
|
|
|
16 |
|
|
void BRTDfunc $(name)_front |
17 |
|
|
10 |
18 |
|
|
${fRrho} ${fGrho} ${fBrho} |
19 |
|
|
${Rtau} ${Gtau} ${Btau} |
20 |
|
|
0 0 0 |
21 |
|
|
. |
22 |
|
|
0 |
23 |
|
|
9 0 0 0 0 0 0 0 0 0 |
24 |
|
|
|
25 |
|
|
void BRTDfunc $(name)_back |
26 |
|
|
10 |
27 |
|
|
${bRrho} ${bGrho} ${bBrho} |
28 |
|
|
${Rtau} ${Gtau} ${Btau} |
29 |
|
|
0 0 0 |
30 |
|
|
. |
31 |
|
|
0 |
32 |
|
|
9 0 0 0 0 0 0 0 0 0 |
33 |
|
|
'_EOF_' |
34 |
|
|
|
35 |
|
|
echo "# Output generated by $0 from $*" |
36 |
|
|
|
37 |
|
|
cat > /tmp/out$$.fmt << '_EOF_' |
38 |
|
|
|
39 |
|
|
void glass $(name) |
40 |
|
|
0 |
41 |
|
|
0 |
42 |
|
|
3 ${Rtn} ${Gtn} ${Btn} |
43 |
|
|
'_EOF_' |
44 |
|
|
|
45 |
|
|
rcalc -e 'abs(x):if(x,x,-x);and(a,b):if(a,b,a);not(x):if(x,-1,1)' \ |
46 |
|
|
-e 'lum(r,g,b):.265*r+.670*g+.065*b' \ |
47 |
|
|
-e 'trans=lum(Rtau,Gtau,Btau)' \ |
48 |
|
|
-e 'rfront=lum(fRrho,fGrho,fBrho);rback=lum(bRrho,bGrho,bBrho)' \ |
49 |
|
|
-e 'cond=0.005-abs(rfront-rback)' \ |
50 |
|
|
-i /tmp/opt.fmt -o /tmp/out$$.fmt $* |
51 |
|
|
|
52 |
|
|
cat > /tmp/out$$.fmt << '_EOF_' |
53 |
|
|
|
54 |
|
|
void BRTDfunc $(name) |
55 |
|
|
10 |
56 |
|
|
rR_clear rG_clear rB_clear |
57 |
|
|
${Rtau}*tR_clear ${Gtau}*tG_clear ${Btau}*tB_clear |
58 |
|
|
0 0 0 |
59 |
|
|
window.cal |
60 |
|
|
0 |
61 |
|
|
15 0 0 0 0 0 0 0 0 0 |
62 |
|
|
${fRrho} ${fGrho} ${fBrho} |
63 |
|
|
${bRrho} ${bGrho} ${bBrho} |
64 |
|
|
'_EOF_' |
65 |
|
|
|
66 |
|
|
rcalc -e 'abs(x):if(x,x,-x);and(a,b):if(a,b,a);not(x):if(x,-1,1)' \ |
67 |
|
|
-e 'lum(r,g,b):.265*r+.670*g+.065*b' \ |
68 |
|
|
-e 'trans=lum(Rtau,Gtau,Btau)' \ |
69 |
|
|
-e 'rfront=lum(fRrho,fGrho,fBrho);rback=lum(bRrho,bGrho,bBrho)' \ |
70 |
|
|
-e 'cond=and(trans-.645, not(0.005-abs(rfront-rback)))' \ |
71 |
|
|
-i /tmp/opt.fmt -o /tmp/out$$.fmt $* |
72 |
|
|
|
73 |
|
|
cat > /tmp/out$$.fmt << '_EOF_' |
74 |
|
|
|
75 |
|
|
void BRTDfunc $(name) |
76 |
|
|
10 |
77 |
|
|
rR_bronze rG_bronze rB_bronze |
78 |
|
|
${Rtau}*tR_bronze ${Gtau}*tG_bronze ${Btau}*tB_bronze |
79 |
|
|
0 0 0 |
80 |
|
|
window.cal |
81 |
|
|
0 |
82 |
|
|
15 0 0 0 0 0 0 0 0 0 |
83 |
|
|
${fRrho} ${fGrho} ${fBrho} |
84 |
|
|
${bRrho} ${bGrho} ${bBrho} |
85 |
|
|
'_EOF_' |
86 |
|
|
|
87 |
|
|
rcalc -e 'abs(x):if(x,x,-x);and(a,b):if(a,b,a);not(x):if(x,-1,1)' \ |
88 |
|
|
-e 'lum(r,g,b):.265*r+.670*g+.065*b' \ |
89 |
|
|
-e 'trans=lum(Rtau,Gtau,Btau)' \ |
90 |
|
|
-e 'rfront=lum(fRrho,fGrho,fBrho);rback=lum(bRrho,bGrho,bBrho)' \ |
91 |
|
|
-e 'cond=and(not(trans-.645), not(0.005-abs(rfront-rback)))' \ |
92 |
|
|
-i /tmp/opt.fmt -o /tmp/out$$.fmt $* |
93 |
|
|
|
94 |
|
|
rm -f /tmp/opt.fmt /tmp/out$$.fmt |