ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/compamb.csh
Revision: 3.7
Committed: Mon Aug 25 04:50:32 2008 UTC (16 years, 3 months ago) by greg
Content type: application/x-csh
Branch: MAIN
CVS Tags: rad5R4, rad5R2, rad4R2P2, rad5R0, rad5R1, rad4R2, rad4R1, rad4R0, rad4R2P1, rad5R3, HEAD
Changes since 3.6: +4 -3 lines
Log Message:
Made temporary files safe from malicious attackers

File Contents

# Content
1 #!/bin/csh -f
2 # RCSid: $Id: compamb.csh,v 3.6 2005/02/16 05:40:11 greg Exp $
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 td=`mktemp -d /tmp/ca.XXXXXX`
26 set tf=$td/compamb
27 set oct=`rad -w -s -e -v 0 $argv[1] QUA=High AMB=$tf.amb OPT=$tf.opt | sed -n 's/^OCTREE= //p'`
28 rad -n -s -V $argv[1] \
29 | rpict @$tf.opt -av 0 0 0 -aw 16 -dv- -S 1 -x 16 -y 16 -ps 1 $oct \
30 | ra_rgbe - '\!pvalue -h -H -d' > $tf.dat
31 echo \# Rad input file modified by $0 `date` >> $argv[1]
32 if ( $?doexpos ) then
33 (echo -n 'EXPOSURE= '; \
34 total -u $tf.dat | rcalc -e '$1=2/(.265*$1+.670*$2+.065*$3)') \
35 >> $argv[1]
36 endif
37 lookamb -h -d $tf.amb | rcalc -e '$1=$10;$2=$11;$3=$12' >> $tf.dat
38 set lavg=`rcalc -e '$1=lum;lum=.265*$1+.670*$2+.065*$3;cond=lum-1e-5' $tf.dat | total -m -p`
39 if ( $?docolor ) then
40 set cavg=(`total -m $tf.dat`)
41 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'`)
42 else
43 set av=($lavg $lavg $lavg)
44 endif
45 echo "render= -av $av" >> $argv[1]
46 quit:
47 exec rm -r $td