ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/compamb.csh
Revision: 3.2
Committed: Wed Jan 28 10:47:11 1998 UTC (26 years, 2 months ago) by gwlarson
Content type: application/x-csh
Branch: MAIN
Changes since 3.1: +1 -1 lines
Log Message:
serious bug fix

File Contents

# Content
1 #!/bin/csh -f
2 # SCCSid "$SunId$ SGI"
3 #
4 # Compute best ambient value for a scene and append to rad input file
5 #
6 while ( $#argv > 1 )
7 switch ( $argv[1] )
8 case -e:
9 set doexpos
10 breaksw
11 case -c:
12 set docolor
13 breaksw
14 default:
15 goto userr
16 endsw
17 shift argv
18 end
19 userr:
20 if ( $#argv != 1 ) then
21 echo Usage: $0 [-e][-c] rad_input_file
22 exit 1
23 endif
24 onintr quit
25 set tf=/usr/tmp/ca$$
26 set oct=`rad -w -s -e -v 0 $argv[1] QUA=High AMB=$tf.amb OPT=$tf.opt | sed -n 's/^OCTREE= //p'`
27 rad -n -s -V $argv[1] \
28 | rpict @$tf.opt -av 0 0 0 -aw 16 -dv- -S 1 -x 16 -y 16 -ps 1 $oct \
29 | ra_rgbe - '\!pvalue -h -H -d' > $tf.dat
30 if ( $?doexpos ) then
31 (echo -n 'EXPOSURE= '; \
32 total -u $tf.dat | rcalc -e '$1=1/(.265*$1+.670*$2+.065*$3)') \
33 >> $argv[1]
34 endif
35 lookamb -h -d $tf.amb | rcalc -e '$1=$10;$2=$11;$3=$12' >> $tf.dat
36 set lavg=`rcalc -e '$1=lum;lum=.265*$1+.670*$2+.065*$3;cond=lum-1e-5' $tf.dat | total -m -p`
37 if ( $?docolor ) then
38 set cavg=(`total -m $tf.dat`)
39 set av=(`rcalc -n -e "r=$cavg[1];g=$cavg[2];b=$cavg[3];sf=$lavg/(.265*r+.670*g+.065*b)" -e '$1=sf*r;$2=sf*g;$3=sf*b'`)
40 else
41 set av=($lavg $lavg $lavg)
42 endif
43 echo "render= -av $av" >> $argv[1]
44 quit:
45 exec rm -f $tf.{amb,opt,dat}