ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/gen/glaze.csh
Revision: 2.2
Committed: Mon Jun 30 18:12:24 2003 UTC (20 years, 9 months ago) by greg
Content type: application/x-csh
Branch: MAIN
Changes since 2.1: +3 -1 lines
Log Message:
Updated Fresnel approximation

File Contents

# Content
1 #!/bin/csh -f
2 # RCSid: $Id: glaze.csh,v 2.1 2003/02/22 02:07:23 greg Exp $
3 #
4 # Complex glazing model (goes with glaze1.cal and glaze2.cal)
5 #
6 # Oct. 2002 Greg Ward
7 # Funding for this development generously provided by Visarc, Inc.
8 # (http://www.vizarc.com)
9 #
10
11 #################################################################
12 #
13 # Supported surface types:
14 #
15 set sn_arr=("clear glass" "VE1-2M low-E coating" "PVB laminated" "V-175 white frit" "V-933 warm gray frit")
16 # Glass-side hemispherical reflectances for each surface type:
17 set rg_r_arr=(0.074 0.065 .11 0.33 0.15)
18 set rg_g_arr=(0.077 0.058 .11 0.33 0.15)
19 set rg_b_arr=(0.079 0.067 .11 0.33 0.15)
20 # Coating-side hemispherical reflectance for each surface type:
21 set rc_r_arr=(0.074 0.042 .11 0.59 0.21)
22 set rc_g_arr=(0.077 0.049 .11 0.59 0.21)
23 set rc_b_arr=(0.079 0.043 .11 0.59 0.21)
24 # Hemispherical (normal) transmittance for each surface type:
25 set tn_r_arr=(0.862 0.756 0.63 0.21 0.09)
26 set tn_g_arr=(0.890 0.808 0.63 0.21 0.09)
27 set tn_b_arr=(0.886 0.744 0.63 0.21 0.09)
28 # Boolean whether coatings can have partial coverage:
29 set part_arr=(0 0 0 1 1)
30
31 #################################################################
32 #
33 # Get user input
34 #
35 echo -n "Enter the number of panes in the system: "
36 set np="$<"
37 if ($np != 1 && $np != 2) then
38 echo "Must be 1 or 2 pane system"
39 exit 1
40 endif
41 echo ""
42 echo "Window normal faces interior"
43 echo ""
44 if ($np == 1) then
45 echo " | |"
46 echo " | |"
47 echo " | |"
48 echo " | |-->"
49 echo " | |"
50 echo " | |"
51 echo " | |"
52 echo " s1 s2"
53 else
54 echo " | | | |"
55 echo " | | | |"
56 echo " | | | |"
57 echo " | | | |-->"
58 echo " | | | |"
59 echo " | | | |"
60 echo " | | | |"
61 echo " s1 s2 s3 s4"
62 endif
63 echo ""
64 echo "Supported surface types are:"
65 set i=1
66 while ($i <= $#sn_arr)
67 echo " " $i - $sn_arr[$i]
68 @ i++
69 end
70 echo ""
71 echo -n "What is the type of s1? "
72 set s1t="$<"
73 echo -n "What is the type of s2? "
74 set s2t="$<"
75 if ($s1t != 1 && $s2t != 1) then
76 echo "One surface of each pane must be $sn_arr[1]"
77 exit 1
78 endif
79 if ($part_arr[$s1t]) then
80 echo -n "Enter fraction coverage for s1 (0-1): "
81 set s1c="$<"
82 endif
83 if ($part_arr[$s2t]) then
84 echo -n "Enter fraction coverage for s2 (0-1): "
85 set s2c="$<"
86 endif
87 if ($np == 2) then
88 echo -n "What is the type of s3? "
89 set s3t="$<"
90 echo -n "What is the type of s4? "
91 set s4t="$<"
92 if ($s3t != 1 && $s4t != 1) then
93 echo "One surface of each pane must be $sn_arr[1]"
94 exit 1
95 endif
96 if ($part_arr[$s3t]) then
97 echo -n "Enter fraction coverage for s3 (0-1): "
98 set s3c="$<"
99 endif
100 if ($part_arr[$s4t]) then
101 echo -n "Enter fraction coverage for s4 (0-1): "
102 set s4c="$<"
103 endif
104 endif
105
106 #################################################################
107 #
108 # Begin material comments
109 #
110 echo ""
111 echo "############################################"
112 echo "# Glazing produced by Radiance glaze script"
113 echo "# `date`"
114 echo "# Material surface normal points to interior"
115 echo "# Number of panes in system: $np"
116
117 if ($np == 2) goto glaze2
118 #################################################################
119 #
120 # Compute single glazing
121 #
122 set sc=1
123 echo "# Exterior surface s1 type: $sn_arr[$s1t]"
124 if ($?s1c) then
125 echo "# s1 coating coverage: $s1c"
126 set sc=$s1c
127 endif
128 echo "# Interior surface s2 type: $sn_arr[$s2t]"
129 if ($?s2c) then
130 echo "# s2 coating coverage: $s2c"
131 set sc=$s2c
132 endif
133 if ($s1t != 1) then
134 set ct=$s1t
135 echo -n "# Exterior normal hemispherical reflectance: "
136 ev ".265*($sc*$rc_r_arr[$ct]+(1-$sc)*$rc_r_arr[1])+.670*($sc*$rc_g_arr[$ct]+(1-$sc)*$rc_g_arr[1])+.065*($sc*$rc_b_arr[$ct]+(1-$sc)*$rc_b_arr[1])"
137 echo -n "# Interior normal hemispherical reflectance: "
138 ev ".265*($sc*$rg_r_arr[$ct]+(1-$sc)*$rg_r_arr[1])+.670*($sc*$rg_g_arr[$ct]+(1-$sc)*$rg_g_arr[1])+.065*($sc*$rg_b_arr[$ct]+(1-$sc)*$rg_b_arr[1])"
139 else
140 set ct=$s2t
141 echo -n "# Exterior normal hemispherical reflectance: "
142 ev ".265*($sc*$rg_r_arr[$ct]+(1-$sc)*$rg_r_arr[1])+.670*($sc*$rg_g_arr[$ct]+(1-$sc)*$rg_g_arr[1])+.065*($sc*$rg_b_arr[$ct]+(1-$sc)*$rg_b_arr[1])"
143 echo -n "# Interior normal hemispherical reflectance: "
144 ev ".265*($sc*$rc_r_arr[$ct]+(1-$sc)*$rc_r_arr[1])+.670*($sc*$rc_g_arr[$ct]+(1-$sc)*$rc_g_arr[1])+.065*($sc*$rc_b_arr[$ct]+(1-$sc)*$rc_b_arr[1])"
145 endif
146 echo -n "# Normal hemispherical transmittance: "
147 ev ".265*($sc*$tn_r_arr[$ct]+(1-$sc)*$tn_r_arr[1])+.670*($sc*$tn_g_arr[$ct]+(1-$sc)*$tn_g_arr[1])+.065*($sc*$tn_b_arr[$ct]+(1-$sc)*$tn_b_arr[1])"
148 echo "#"
149 echo "void BRTDfunc glaze1_unnamed"
150 if ($part_arr[$s1t] || $part_arr[$s2t]) then
151 ### Frit glazing
152 echo "10"
153 echo " sr_frit_r sr_frit_g sr_frit_b"
154 echo " st_frit_r st_frit_g st_frit_b"
155 echo " 0 0 0"
156 echo " glaze1.cal"
157 echo "0"
158 echo "11"
159 if ($s2t == 1) then
160 ev "$s1c*($rg_r_arr[$s1t]-$rg_r_arr[1])" \
161 "$s1c*($rg_g_arr[$s1t]-$rg_g_arr[1])" \
162 "$s1c*($rg_b_arr[$s1t]-$rg_b_arr[1])"
163 ev "$s1c*$rc_r_arr[$s1t]" "$s1c*$rc_g_arr[$s1t]" "$s1c*$rc_b_arr[$s1t]"
164 ev "$s1c*$tn_r_arr[$s1t]" "$s1c*$tn_g_arr[$s1t]" "$s1c*$tn_b_arr[$s1t]"
165 echo " 1 $s1c"
166 else
167 ev "$s2c*$rc_r_arr[$s2t]" "$s2c*$rc_g_arr[$s2t]" "$s2c*$rc_b_arr[$s2t]"
168 ev "$s2c*($rg_r_arr[$s2t]-$rg_r_arr[1])" \
169 "$s2c*($rg_g_arr[$s2t]-$rg_g_arr[1])" \
170 "$s2c*($rg_b_arr[$s2t]-$rg_b_arr[1])"
171 ev "$s2c*$tn_r_arr[$s2t]" "$s2c*$tn_g_arr[$s2t]" "$s2c*$tn_b_arr[$s2t]"
172 echo " -1 $s2c"
173 endif
174 else
175 ### Low-E glazing
176 echo "10"
177 echo " sr_lowE_r sr_lowE_g sr_lowE_b"
178 echo " st_lowE_r st_lowE_g st_lowE_b"
179 echo " 0 0 0"
180 echo " glaze1.cal"
181 echo "0"
182 echo "19"
183 echo " 0 0 0"
184 echo " 0 0 0"
185 echo " 0 0 0"
186 if ($s2t == 1) then
187 echo " 1"
188 set st=$s1t
189 else
190 echo " -1"
191 set st=$s2t
192 endif
193 echo " $rg_r_arr[$st] $rg_g_arr[$st] $rg_b_arr[$st]"
194 echo " $rc_r_arr[$st] $rc_g_arr[$st] $rc_b_arr[$st]"
195 echo " $tn_r_arr[$st] $tn_g_arr[$st] $tn_b_arr[$st]"
196 endif
197 echo ""
198 exit 0
199
200 glaze2:
201 #################################################################
202 #
203 # Compute double glazing
204 #
205 if ($s2t != 1) then
206 set s2r_rgb=($rc_r_arr[$s2t] $rc_g_arr[$s2t] $rc_b_arr[$s2t])
207 set s1r_rgb=($rg_r_arr[$s2t] $rg_g_arr[$s2t] $rg_b_arr[$s2t])
208 set s12t_rgb=($tn_r_arr[$s2t] $tn_g_arr[$s2t] $tn_b_arr[$s2t])
209 else
210 set s2r_rgb=($rg_r_arr[$s1t] $rg_g_arr[$s1t] $rg_b_arr[$s1t])
211 set s1r_rgb=($rc_r_arr[$s1t] $rc_g_arr[$s1t] $rc_b_arr[$s1t])
212 set s12t_rgb=($tn_r_arr[$s1t] $tn_g_arr[$s1t] $tn_b_arr[$s1t])
213 endif
214 if ($s4t != 1) then
215 set s4r_rgb=($rc_r_arr[$s4t] $rc_g_arr[$s4t] $rc_b_arr[$s4t])
216 set s3r_rgb=($rg_r_arr[$s4t] $rg_g_arr[$s4t] $rg_b_arr[$s4t])
217 set s34t_rgb=($tn_r_arr[$s4t] $tn_g_arr[$s4t] $tn_b_arr[$s4t])
218 else
219 set s4r_rgb=($rg_r_arr[$s3t] $rg_g_arr[$s3t] $rg_b_arr[$s3t])
220 set s3r_rgb=($rc_r_arr[$s3t] $rc_g_arr[$s3t] $rc_b_arr[$s3t])
221 set s34t_rgb=($tn_r_arr[$s3t] $tn_g_arr[$s3t] $tn_b_arr[$s3t])
222 endif
223 set s12c=1
224 echo "# Exterior surface s1 type: $sn_arr[$s1t]"
225 if ($?s1c) then
226 echo "# s1 coating coverage: $s1c"
227 set s12c=$s1c
228 endif
229 echo "# Inner surface s2 type: $sn_arr[$s2t]"
230 if ($?s2c) then
231 echo "# s2 coating coverage: $s2c"
232 set s12c=$s2c
233 endif
234 set s34c=1
235 echo "# Inner surface s3 type: $sn_arr[$s3t]"
236 if ($?s3c) then
237 echo "# s3 coating coverage: $s3c"
238 set s34c=$s3c
239 endif
240 echo "# Interior surface s4 type: $sn_arr[$s4t]"
241 if ($?s4c) then
242 echo "# s4 coating coverage: $s4c"
243 set s34c=$s4c
244 endif
245 # Approximate reflectance and transmittance for comment using gray values
246 set rglass=`ev ".265*$rg_r_arr[1]+.670*$rg_g_arr[1]+.065*$rg_b_arr[1]"`
247 set tglass=`ev ".265*$tn_r_arr[1]+.670*$tn_g_arr[1]+.065*$tn_b_arr[1]"`
248 set s1r_gry=`ev "$s12c*(.265*$s1r_rgb[1]+.670*$s1r_rgb[2]+.065*$s1r_rgb[3])+(1-$s12c)*$rglass"`
249 set s2r_gry=`ev "$s12c*(.265*$s2r_rgb[1]+.670*$s2r_rgb[2]+.065*$s2r_rgb[3])+(1-$s12c)*$rglass"`
250 set s12t_gry=`ev "$s12c*(.265*$s12t_rgb[1]+.670*$s12t_rgb[2]+.065*$s12t_rgb[3])+(1-$s12c)*$tglass"`
251 set s3r_gry=`ev "$s34c*(.265*$s3r_rgb[1]+.670*$s3r_rgb[2]+.065*$s3r_rgb[3])+(1-$s34c)*$rglass"`
252 set s4r_gry=`ev "$s34c*(.265*$s4r_rgb[1]+.670*$s4r_rgb[2]+.065*$s4r_rgb[3])+(1-$s34c)*$rglass"`
253 set s34t_gry=`ev "$s34c*(.265*$s34t_rgb[1]+.670*$s34t_rgb[2]+.065*$s34t_rgb[3])+(1-$s34c)*$tglass"`
254 echo -n "# Exterior normal hemispherical reflectance: "
255 ev "$s1r_gry + $s12t_gry^2*$s3r_gry"
256 echo -n "# Interior normal hemispherical reflectance: "
257 ev "$s4r_gry + $s34t_gry^2*$s2r_gry"
258 echo -n "# Normal hemispherical transmittance: "
259 ev "$s12t_gry*$s34t_gry"
260 echo "#"
261 echo "void BRTDfunc glaze2_unnamed"
262
263 if ($part_arr[$s3t] || $part_arr[$s4t]) then
264 ### Front pane has frit
265 if ($part_arr[$s1t] || $part_arr[$s2t]) then
266 echo "Only one pane can have frit"
267 exit 1
268 endif
269 if ($?s3c) then
270 set sc=$s3c
271 set s3g=`ev "1-$s3c"`
272 else
273 set s3c=0
274 set s3g=1
275 endif
276 if ($?s4c) then
277 set sc=$s4c
278 set s4g=`ev "1-$s4c"`
279 else
280 set s4c=0
281 set s4g=1
282 endif
283 echo "10"
284 echo "if(Rdot,cr($s4g*rclr,$s3g*$s4g*tclr,fr($s2r_rgb[1])),cr(fr($s1r_rgb[1]),ft($s12t_rgb[1]),$s3g*rclr))"
285 echo "if(Rdot,cr($s4g*rclr,$s3g*$s4g*tclr,fr($s2r_rgb[2])),cr(fr($s1r_rgb[2]),ft($s12t_rgb[2]),$s3g*rclr))"
286 echo "if(Rdot,cr($s4g*rclr,$s3g*$s4g*tclr,fr($s2r_rgb[3])),cr(fr($s1r_rgb[3]),ft($s12t_rgb[3]),$s3g*rclr))"
287 echo "$s3g*$s4g*ft($s12t_rgb[1])*tclr"
288 echo "$s3g*$s4g*ft($s12t_rgb[2])*tclr"
289 echo "$s3g*$s4g*ft($s12t_rgb[3])*tclr"
290 echo " 0 0 0"
291 echo " glaze2.cal"
292 echo "0"
293 echo "9"
294 ev "$sc*$s4r_rgb[1]-$s3c*$rg_r_arr[1]" \
295 "$sc*$s4r_rgb[2]-$s3c*$rg_g_arr[1]" \
296 "$sc*$s4r_rgb[3]-$s3c*$rg_b_arr[1]"
297 ev "$s12t_rgb[1]^2*($sc*$s3r_rgb[1]-$s4c*$rg_r_arr[1])" \
298 "$s12t_rgb[2]^2*($sc*$s3r_rgb[2]-$s4c*$rg_g_arr[1])" \
299 "$s12t_rgb[3]^2*($sc*$s3r_rgb[3]-$s4c*$rg_b_arr[1])"
300 ev "$sc*$s12t_rgb[1]*$s34t_rgb[1]" \
301 "$sc*$s12t_rgb[2]*$s34t_rgb[2]" \
302 "$sc*$s12t_rgb[3]*$s34t_rgb[3]"
303 else if ($part_arr[$s1t] || $part_arr[$s2t]) then
304 ### Back pane has frit
305 if ($?s1c) then
306 set sc=$s1c
307 set s1g=`ev "1-$s1c"`
308 else
309 set s1c=0
310 set s1g=1
311 endif
312 if ($?s2c) then
313 set sc=$s2c
314 set s2g=`ev "1-$s2c"`
315 else
316 set s2c=0
317 set s2g=1
318 endif
319 echo "10"
320 echo "if(Rdot,cr(fr($s4r_rgb[1]),ft($s34t_rgb[1]),$s2g*rclr),cr($s1g*rclr,$s1g*$s2g*tclr,fr($s3r_rgb[1])))"
321 echo "if(Rdot,cr(fr($s4r_rgb[2]),ft($s34t_rgb[2]),$s2g*rclr),cr($s1g*rclr,$s1g*$s2g*tclr,fr($s3r_rgb[2])))"
322 echo "if(Rdot,cr(fr($s4r_rgb[3]),ft($s34t_rgb[3]),$s2g*rclr),cr($s1g*rclr,$s1g*$s2g*tclr,fr($s3r_rgb[3])))"
323 echo "$s1g*$s2g*ft($s34t_rgb[1])*tclr"
324 echo "$s1g*$s2g*ft($s34t_rgb[2])*tclr"
325 echo "$s1g*$s2g*ft($s34t_rgb[3])*tclr"
326 echo " 0 0 0"
327 echo " glaze2.cal"
328 echo "0"
329 echo "9"
330 ev "$s34t_rgb[1]^2*($sc*$s2r_rgb[1]-$s1c*$rg_r_arr[1])" \
331 "$s34t_rgb[2]^2*($sc*$s2r_rgb[2]-$s1c*$rg_g_arr[1])" \
332 "$s34t_rgb[3]^2*($sc*$s2r_rgb[3]-$s1c*$rg_b_arr[1])"
333 ev "$sc*$s1r_rgb[1]-$s2c*$rg_r_arr[1]" \
334 "$sc*$s1r_rgb[2]-$s2c*$rg_g_arr[1]" \
335 "$sc*$s1r_rgb[3]-$s2c*$rg_b_arr[1]"
336 ev "$sc*$s34t_rgb[1]*$s12t_rgb[1]" \
337 "$sc*$s34t_rgb[2]*$s12t_rgb[2]" \
338 "$sc*$s34t_rgb[3]*$s12t_rgb[3]"
339 else
340 ### Low-E and regular glazing only
341 echo "10"
342 echo "if(Rdot,cr(fr($s4r_rgb[1]),ft($s34t_rgb[1]),fr($s2r_rgb[1])),cr(fr($s1r_rgb[1]),ft($s12t_rgb[1]),fr($s3r_rgb[1])))"
343 echo "if(Rdot,cr(fr($s4r_rgb[2]),ft($s34t_rgb[2]),fr($s2r_rgb[2])),cr(fr($s1r_rgb[2]),ft($s12t_rgb[2]),fr($s3r_rgb[2])))"
344 echo "if(Rdot,cr(fr($s4r_rgb[3]),ft($s34t_rgb[3]),fr($s2r_rgb[3])),cr(fr($s1r_rgb[3]),ft($s12t_rgb[3]),fr($s3r_rgb[3])))"
345 echo "ft($s34t_rgb[1])*ft($s12t_rgb[1])"
346 echo "ft($s34t_rgb[2])*ft($s12t_rgb[2])"
347 echo "ft($s34t_rgb[3])*ft($s12t_rgb[3])"
348 echo " 0 0 0"
349 echo " glaze2.cal"
350 echo "0"
351 echo "9"
352 echo " 0 0 0"
353 echo " 0 0 0"
354 echo " 0 0 0"
355 endif
356 echo ""
357 exit 0