print out random variables and expression evaluation time

   2965   2   2
User Avatar
Member
30 posts
Joined: July 2005
Offline
hello, i want to input random values to some parameters for a shader and see what kinds of images those random parameters would produce i want to keep a record of what random values were used also so i could use the same values in the future.

i am using hscript + shell scripting. i was trying two ways of doing this.

1) use a random expression for the shader variable. i.e. rand(system(date))
i was using the example hscript+unix shell scripts.


#! /bin/csh -f

#check to see if user suppled the correct number of arguments
#- exit if not

if ($#argv < 4) then
echo “USEAGE: ren_script <hip_file> <out_file> <start> <end>”
exit
endif

# set up user supplied arguments

set HIP_FILE = $1
set OUT_FILE = $2
set START = $3
set END = $4
set TEST

for i = $START to $END
echo ‘ch(“/obj/geo1/tx”)’
end

ENDCAT


the problem for this particular situation is:

-echo just prints out ‘ch(“/obj/geo1/tx”)’ instead of the actual value. in the textport window, this command works and prints out 0

-im not sure when the expression is evaluated. is the expression evaluated only when it is currently being rendered. unfortunately since echo was not working, i could not extract the value of the variable. would i have to “cook” the shader first in order to find out what the random variable would be?


2) feed the *.hip file a random number i generated in the unix shell. i.e. using gawk srand() and rand() functions.
i am havint all sorts of problems with this, i think this may be working:

set randomnumber = system( “unix gawk ‘BEGIN { srand();print rand() }’”)

problem is, i have this for loop



#! /bin/csh -f

#check to see if user suppled the correct number of arguments
#- exit if not

if ($#argv < 4) then
echo “USEAGE: ren_script <hip_file> <out_file> <start> <end>”
exit
endif

# set up user supplied arguments

set HIP_FILE = $1
set OUT_FILE = $2
set START = $3
set END = $4
set TEST = 22

for i = $START to $END
set TEST = 44
echo $TEST
end

ENDCAT



this doesnt set TEST for some reason and just prints out 22 when it should be 44, so i am not able to set the shader variable.
User Avatar
Member
2199 posts
Joined: July 2005
Online
I haven't tested this but try escaping the single quotes with a \

so



echo ‘ch(“/obj/geo1/tx”)’

becomes

echo \'ch(“/obj/geo1/tx”)\'

Also in your second example it might be worth using setenv or set -g instead of just set. This will make the variables global and might do the trick.
The trick is finding just the right hammer for every screw
User Avatar
Member
321 posts
Joined: July 2005
Offline
To have an expression (like ch() ) evaluate, you need to put it in backticks – `, not ‘.

Also, ch() will just tell you what it is, it won’t set it. For that, you'll need the ‘opparm’ command.

– Antoine
Antoine Durr
Floq FX
antoine@floqfx.com
_________________
  • Quick Links