orig/compamb.csh
author Axel Jacobs <axel@jaloxa.eu>
Mon, 14 Apr 2014 22:21:17 +0100
changeset 73 87fa3132a136
parent 0 0aa115157c9c
permissions -rw-r--r--
New IES test file with spaces in file name
     1 #!/bin/csh -f
     2 # RCSid: $Id: compamb.csh,v 3.7 2008/08/25 04:50:32 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