Hey All,
I'm pretty lousy at coding so please excuse, but I'm trying to create a simple render script much like the third example in the Scripting pdf
My problem is I'm trying to create an outfile in the format “outfile.$F4.ext” which works fine except the frame numbers don't update each frame.
I get outfile.0001.pic but subsequent frames just overwrite the first image. I could use fcur and get the frame number but how do I pad it then?
Any help appreciated
Thanks
tcsh, linux
Need Help with render script
8169 13 1- tallkien
- Member
- 225 posts
- Joined: July 2005
- Offline
- JColdrick
- Member
- 4140 posts
- Joined: July 2005
- Offline
More than likely the shell that executes the script sees “$F4” and says “oh - you need $F? Here - it's ”0001“ - which *then* gets passed to hscript, who dutifully renders each pass with that value. Welcome to the Wonderful World of Shell Escapes.
What you need to to is tell the shell to pass that ”$“ and not try to expand anything - this is done by sticking a ”\“ in front, as in:
outfile.\$F4.ext
Houdini will now received ”$F4" and will expand appropriately…
Cheers,
J.C.
What you need to to is tell the shell to pass that ”$“ and not try to expand anything - this is done by sticking a ”\“ in front, as in:
outfile.\$F4.ext
Houdini will now received ”$F4" and will expand appropriately…
Cheers,
J.C.
John Coldrick
- tallkien
- Member
- 225 posts
- Joined: July 2005
- Offline
Duh! coding newbie in need of life support!!!
I've spent the whole day pulling my hair out over this and just now realized i've been trying a
for-to-step type command in tcsh just like the pdf says, a quick RTFM my linux books and man pages and I find there is no “for”, its all while and foreach now :cry:
so whats the new age equivalent of “for i = $start to $end step $inc” in tcsh
I did escape $F4 with \ and managed to render a sequence but when I turned verbose on this is what I get
Rendering 1to 10 by 1
Frame 1
rendering (1 of 10)
rendering (2 of 10)
rendering (3 of10)
……….
……….
rendering (10 of 10)
Frame 2
rendering (1 of 10)
rendering (2 of 10)
……….
………..
rendering (10 of10)
Frame 3
……….
Ofcourse a normally 3 second frame takes something like 20 secs and the frames don't reflect the animation. Frame 1's pic is actually frame 20 something :roll:
someone please throw me a line
ps: is this doable with bash?
I've spent the whole day pulling my hair out over this and just now realized i've been trying a
for-to-step type command in tcsh just like the pdf says, a quick RTFM my linux books and man pages and I find there is no “for”, its all while and foreach now :cry:
so whats the new age equivalent of “for i = $start to $end step $inc” in tcsh
I did escape $F4 with \ and managed to render a sequence but when I turned verbose on this is what I get
Rendering 1to 10 by 1
Frame 1
rendering (1 of 10)
rendering (2 of 10)
rendering (3 of10)
……….
……….
rendering (10 of 10)
Frame 2
rendering (1 of 10)
rendering (2 of 10)
……….
………..
rendering (10 of10)
Frame 3
……….
Ofcourse a normally 3 second frame takes something like 20 secs and the frames don't reflect the animation. Frame 1's pic is actually frame 20 something :roll:
someone please throw me a line
ps: is this doable with bash?
- JColdrick
- Member
- 4140 posts
- Joined: July 2005
- Offline
Hmmm…unless I'm misunderstanding you, you're not approaching this correctly. The “for” loops that are in the examples I remember(although it's been a while since I've looked at them!) *aren't* shell commands - they are hscript commands. You are essentially using the shell to pass a whack o' hscript commands to an hscript session. Can you give a pdf/page number of the one you're trying to run?
You don't want to be doing looping frames in a shell, as a rule, since that means you'll be calling a brand new hscript for every frame. Typically you call an hscript and run a bunch of hscript commands to get what you want. Since you often have to go through a shell to do this, it's important to know about things like the escape char \, but I think you're trying to run hscript code as shell code. Nu-uh.
That's what the “hscript <<ENDCAT” stuff means - it's telling the shell to pass all the text you're about to send to hscript - and stop sending once you hit the characters “<<ENDCAT”. Make sure that stuff is there.
It's also worth noting that you don't *need* to use loops to render - what we usually do is build a ROP on the fly in hscript, set to all the params and ranges you want, then “render foo”. However, cart before the horse - there's nothing wrong with doing loops yourself…
Cheers,
J.C.
You don't want to be doing looping frames in a shell, as a rule, since that means you'll be calling a brand new hscript for every frame. Typically you call an hscript and run a bunch of hscript commands to get what you want. Since you often have to go through a shell to do this, it's important to know about things like the escape char \, but I think you're trying to run hscript code as shell code. Nu-uh.
That's what the “hscript <<ENDCAT” stuff means - it's telling the shell to pass all the text you're about to send to hscript - and stop sending once you hit the characters “<<ENDCAT”. Make sure that stuff is there.
It's also worth noting that you don't *need* to use loops to render - what we usually do is build a ROP on the fly in hscript, set to all the params and ranges you want, then “render foo”. However, cart before the horse - there's nothing wrong with doing loops yourself…
Cheers,
J.C.
John Coldrick
- tallkien
- Member
- 225 posts
- Joined: July 2005
- Offline
Scripting 3.3 page 92-93
Render Outputs 2.2 page 787
and here's me
#! /bin/tcsh -f
if ( $#argv < 4 ) then
echo 'Usage: myRender { Optional: }'
echo ‘set outFile in the format <path/filename.ext>, images will be padded to 4 automatically’
exit
endif
set hipfile = “$1”
set outFile = “$2”
set start = “$3”
set end = “$4”
if ( $#argv == 5 ) then
set inc = “$5”
set rnddriver = “mantra1”
set rndcamera = “cam1”
else if ( $#argv < 5 ) then
set inc = 1
set rnddriver = “mantra1”
set rndcamera = “cam1”
else if ($#argv > 5 ) then
set inc = “$5”
set rnddriver = “$6”
set rndcamera = “$7”
endif
set outPath = $outFile:h
set filename = $outFile:t
set base = $filename:r
set ext = $filename:e
echo ‘Rendering File:’ $hipfile ‘output driver:’ $rnddriver ‘camera:’ $rndcamera
echo ‘ Frame Range:’ $start ‘to’ $end ‘by’ $inc
hscript<<ENDCAT
mread $hipfile
opcd \/out
opparm $rnddriver camera ($rndcamera)
opparm $rnddriver trange ( on ) f ( $start $end $inc )
fcur $start
for frame = “$start” to “$end” step “$inc”
fcur \$frame
set i = \$F4
opparm $rnddriver picture (“$outPath”\/“$base”.\$i.“$ext”)
echo ‘Rendering Frame’ \$frame
render $rnddriver
end
ENDCAT
Each pic is the last frame of the sequence
Render Outputs 2.2 page 787
and here's me
#! /bin/tcsh -f
if ( $#argv < 4 ) then
echo 'Usage: myRender { Optional: }'
echo ‘set outFile in the format <path/filename.ext>, images will be padded to 4 automatically’
exit
endif
set hipfile = “$1”
set outFile = “$2”
set start = “$3”
set end = “$4”
if ( $#argv == 5 ) then
set inc = “$5”
set rnddriver = “mantra1”
set rndcamera = “cam1”
else if ( $#argv < 5 ) then
set inc = 1
set rnddriver = “mantra1”
set rndcamera = “cam1”
else if ($#argv > 5 ) then
set inc = “$5”
set rnddriver = “$6”
set rndcamera = “$7”
endif
set outPath = $outFile:h
set filename = $outFile:t
set base = $filename:r
set ext = $filename:e
echo ‘Rendering File:’ $hipfile ‘output driver:’ $rnddriver ‘camera:’ $rndcamera
echo ‘ Frame Range:’ $start ‘to’ $end ‘by’ $inc
hscript<<ENDCAT
mread $hipfile
opcd \/out
opparm $rnddriver camera ($rndcamera)
opparm $rnddriver trange ( on ) f ( $start $end $inc )
fcur $start
for frame = “$start” to “$end” step “$inc”
fcur \$frame
set i = \$F4
opparm $rnddriver picture (“$outPath”\/“$base”.\$i.“$ext”)
echo ‘Rendering Frame’ \$frame
render $rnddriver
end
ENDCAT
Each pic is the last frame of the sequence
- edward
- Member
- 7694 posts
- Joined: July 2005
- Online
- tallkien
- Member
- 225 posts
- Joined: July 2005
- Offline
edward
I don't know if this will help but have you looked at the hrender script?
vim $HB/hrender
That'll do Edward, That'll do
I had to modify the file slightly to accomadate hipnc files but it works just fine so now I have hrender and nchrender
Still would greatly appreciate if someone can help me debug/improve the above file, at least I might learn something
Thanks a lot
- MatrixNAN
- Member
- 405 posts
- Joined: July 2005
- Offline
I think I might be able to do that.
#! /bin/tcsh -f
is to execute the shell from the HScript.
if ( $#argv < 4 ) then
echo 'Usage: myRender { Optional: }'
echo ‘set outFile in the format <path/filename.ext>, images will be padded to 4 automatically’
exit
endif
If the user did not pass enough parameters or arguements as they are called for the Render command then pass them an error message saying so and what the input should look like.
set hipfile = “$1”
set outFile = “$2”
set start = “$3”
set end = “$4”
the first variable hipfile equals the first argument that is passed in from the render command. the outFile variable takes the second arguement from the render command the start variable takes the third and the end takes the forth argument. Note that the usage said that the parameters should follow the format
myRender { Optional:
Therefore arguement $1 is $2 $3 $4
if ( $#argv == 5 ) then
set inc = “$5”
set rnddriver = “mantra1”
set rndcamera = “cam1”
Since Arguement 5 is optional as denoted in the format response message when the user sent in the wrong number of arguements. If there is 5 arguements then the increment arguement was passed to the render command and the variable inc is set to the fifth arguement. rnddriver variable is set to mantra instead of say mental ray or renderman. rnddriver stands for render driver. the variable rndcamera is set to cam1 which is camera1 to be rendered by mantra.
else if ( $#argv < 5 ) then
set inc = 1
set rnddriver = “mantra1”
set rndcamera = “cam1”
if there was only four render arguements passed then the inc variable is set to 1 or every frame to be rendered. rnddriver and rndcamera are the same as above.
else if ($#argv > 5 ) then
set inc = “$5”
set rnddriver = “$6”
set rndcamera = “$7”
endif
if there is more than 5 arugments passed it is assumed that 7 arguements are passed and the inc varaible is set to the increment of frames. This would be like by frame in maya or -b 1. rnddriver variable is set to the render that will be used arguement six. rndcamera is set to the camera to be rendered from arguement seven.
set outPath = $outFile:h
set filename = $outFile:t
set base = $filename:r
set ext = $filename:e
outPath variable is equal to the directory where the files will be rendered.
filename variable is equal to the filenames of the rendered images.
base variable is equal to the rendered image filename without the extension
ext variable is equal to the rendered image ext type
echo ‘Rendering File:’ $hipfile ‘output driver:’ $rnddriver ‘camera:’ $rndcamera
echo ‘ Frame Range:’ $start ‘to’ $end ‘by’ $inc
says to the user "Rendering File: YourHipFileHere output driver: RenderProgramHere camera: YourCameraHere Frame Range: YourStartingFrameHere to YourEndingFrameHere by YourFrameSteppingHere
hscript<<ENDCAT
Ends the Shell and now entering Hscript in houdini.
mread $hipfile
opcd \/out
opparm $rnddriver camera ($rndcamera)
opparm $rnddriver trange ( on ) f ( $start $end $inc )
fcur $start
mread $hipfile reads in your scene file to be rendered.
the next line sets what camera to render with
the 3rd line sets what render program to use to do the render along with its start end and by frames
the last line sets what the current frame is if I am not mistaken.
for frame = “$start” to “$end” step “$inc”
fcur \$frame
set i = \$F4
opparm $rnddriver picture (“$outPath”\/“$base”.\$i.“$ext”)
echo ‘Rendering Frame’ \$frame
render $rnddriver
end
this is a loop so it will start at frame 1 and will continue to do each frame for every step value up till the last frame. for instance if the by frame is 1 then it will render every frame. If the by frame is 2 then it will render every other frame and 3 every third frame and so on and so on. fcur is set to the current frame that the loop is on. i is set to the current frame number. The next line setups up the render of the frame with the full path name frame number and extentsion. echo command says to the user "Rendering Frame YourFrameNumberHere" The last line of the loop renders the actual frame before it loops back in the for loop to do it again unless of course it has finished rendering the last frame at which point the code exits the loop and thats all of the code.
ENDCAT
Ends the hscript.
Thats All of it I owed you!!! lol
Cheers,
Nate Nesler
#! /bin/tcsh -f
is to execute the shell from the HScript.
if ( $#argv < 4 ) then
echo 'Usage: myRender { Optional: }'
echo ‘set outFile in the format <path/filename.ext>, images will be padded to 4 automatically’
exit
endif
If the user did not pass enough parameters or arguements as they are called for the Render command then pass them an error message saying so and what the input should look like.
set hipfile = “$1”
set outFile = “$2”
set start = “$3”
set end = “$4”
the first variable hipfile equals the first argument that is passed in from the render command. the outFile variable takes the second arguement from the render command the start variable takes the third and the end takes the forth argument. Note that the usage said that the parameters should follow the format
myRender { Optional:
Therefore arguement $1 is $2 $3 $4
if ( $#argv == 5 ) then
set inc = “$5”
set rnddriver = “mantra1”
set rndcamera = “cam1”
Since Arguement 5 is optional as denoted in the format response message when the user sent in the wrong number of arguements. If there is 5 arguements then the increment arguement was passed to the render command and the variable inc is set to the fifth arguement. rnddriver variable is set to mantra instead of say mental ray or renderman. rnddriver stands for render driver. the variable rndcamera is set to cam1 which is camera1 to be rendered by mantra.
else if ( $#argv < 5 ) then
set inc = 1
set rnddriver = “mantra1”
set rndcamera = “cam1”
if there was only four render arguements passed then the inc variable is set to 1 or every frame to be rendered. rnddriver and rndcamera are the same as above.
else if ($#argv > 5 ) then
set inc = “$5”
set rnddriver = “$6”
set rndcamera = “$7”
endif
if there is more than 5 arugments passed it is assumed that 7 arguements are passed and the inc varaible is set to the increment of frames. This would be like by frame in maya or -b 1. rnddriver variable is set to the render that will be used arguement six. rndcamera is set to the camera to be rendered from arguement seven.
set outPath = $outFile:h
set filename = $outFile:t
set base = $filename:r
set ext = $filename:e
outPath variable is equal to the directory where the files will be rendered.
filename variable is equal to the filenames of the rendered images.
base variable is equal to the rendered image filename without the extension
ext variable is equal to the rendered image ext type
echo ‘Rendering File:’ $hipfile ‘output driver:’ $rnddriver ‘camera:’ $rndcamera
echo ‘ Frame Range:’ $start ‘to’ $end ‘by’ $inc
says to the user "Rendering File: YourHipFileHere output driver: RenderProgramHere camera: YourCameraHere Frame Range: YourStartingFrameHere to YourEndingFrameHere by YourFrameSteppingHere
hscript<<ENDCAT
Ends the Shell and now entering Hscript in houdini.
mread $hipfile
opcd \/out
opparm $rnddriver camera ($rndcamera)
opparm $rnddriver trange ( on ) f ( $start $end $inc )
fcur $start
mread $hipfile reads in your scene file to be rendered.
the next line sets what camera to render with
the 3rd line sets what render program to use to do the render along with its start end and by frames
the last line sets what the current frame is if I am not mistaken.
for frame = “$start” to “$end” step “$inc”
fcur \$frame
set i = \$F4
opparm $rnddriver picture (“$outPath”\/“$base”.\$i.“$ext”)
echo ‘Rendering Frame’ \$frame
render $rnddriver
end
this is a loop so it will start at frame 1 and will continue to do each frame for every step value up till the last frame. for instance if the by frame is 1 then it will render every frame. If the by frame is 2 then it will render every other frame and 3 every third frame and so on and so on. fcur is set to the current frame that the loop is on. i is set to the current frame number. The next line setups up the render of the frame with the full path name frame number and extentsion. echo command says to the user "Rendering Frame YourFrameNumberHere" The last line of the loop renders the actual frame before it loops back in the for loop to do it again unless of course it has finished rendering the last frame at which point the code exits the loop and thats all of the code.
ENDCAT
Ends the hscript.
Thats All of it I owed you!!! lol
Cheers,
Nate Nesler
- JColdrick
- Member
- 4140 posts
- Joined: July 2005
- Offline
Phew! I never could have found the time, Nate!
Haven't really read this, but I assume it's got something busted in it and I'm not sure you found what that was, but still…
One thing I would point out is that the whole mechanism of using a loop to render multiple frames is really a holdover from the old days when that was the only way to do it - ROPs didn't exist. It's not really necessary now unless you need to tweak something between frames - typically not necessary since almost everything can be animated. If you just set:
opparm $rnddriver trange ( on ) f ($start $end $inc)
render $rnddriver
You're done.
Cheers,
J.C.
Haven't really read this, but I assume it's got something busted in it and I'm not sure you found what that was, but still…
One thing I would point out is that the whole mechanism of using a loop to render multiple frames is really a holdover from the old days when that was the only way to do it - ROPs didn't exist. It's not really necessary now unless you need to tweak something between frames - typically not necessary since almost everything can be animated. If you just set:
opparm $rnddriver trange ( on ) f ($start $end $inc)
render $rnddriver
You're done.
Cheers,
J.C.
John Coldrick
- MatrixNAN
- Member
- 405 posts
- Joined: July 2005
- Offline
- tallkien
- Member
- 225 posts
- Joined: July 2005
- Offline
Thanks a lot Nate, You just broke down the code I put together myself, Actually I just wanted it debugged, the problem is in the earlier post but I REALLY do appreciate the gesture, Thanks a lot buddy 8)
Ya Its looping within the loop, not sure how or why. Will take another whack at it when I have more time. Must be something to do with $F . This whole exercise was to be able to render on my second cpu while working on the first. hrender does that fine, so does hscript myfile.hip -> render $driver. I just didn't know about these options.
Thanks a lot guys
Ya Its looping within the loop, not sure how or why. Will take another whack at it when I have more time. Must be something to do with $F . This whole exercise was to be able to render on my second cpu while working on the first. hrender does that fine, so does hscript myfile.hip -> render $driver. I just didn't know about these options.
Thanks a lot guys
- MatrixNAN
- Member
- 405 posts
- Joined: July 2005
- Offline
Hey Tallkien,
Oh I misunderstood. I thought you got that code out of a tutorial in the PDFs in the scripting tuts and needed to understand it. Well instead of doing the loop you could just do what JColdrick wrote. I would think it would work. Although I really do not see a bug in your code very odd. I will have to look at it some more.
Cheers,
Nate Nesler
Oh I misunderstood. I thought you got that code out of a tutorial in the PDFs in the scripting tuts and needed to understand it. Well instead of doing the loop you could just do what JColdrick wrote. I would think it would work. Although I really do not see a bug in your code very odd. I will have to look at it some more.
Cheers,
Nate Nesler
- MatrixNAN
- Member
- 405 posts
- Joined: July 2005
- Offline
Hey Tallkien,
I would just replace the loop with the code JColdrick posted and then you will not even have to worry about a double loop senario. I guess thats what I get for trying to read posts on no sleep. lol
JColdrick
opparm $rnddriver trange ( on ) f ($start $end $inc)
render $rnddriver
I suspect the actual problem with the loop is
set i = \$F4
prehaps if you did
set i = \$Frame
it would not double loop. I am saying this because from the code structure that loops like the only place for a leak besides having values passed under the hood of Houdini where you do not see those interactions going on. I suspect but I have not proven that \$F4 is passing the whole sequence of frames and causes an internal loop within the
opparm $rnddriver picture (“$outPath”\/“$base”.\$i.“$ext”)
And a recurvise function would then occur when the command
render $rnddriver
was called. There by rendering all the frames every loop interation. Thats my best guess at this point.
Cheers,
Nate Nesler
I would just replace the loop with the code JColdrick posted and then you will not even have to worry about a double loop senario. I guess thats what I get for trying to read posts on no sleep. lol
JColdrick
opparm $rnddriver trange ( on ) f ($start $end $inc)
render $rnddriver
I suspect the actual problem with the loop is
set i = \$F4
prehaps if you did
set i = \$Frame
it would not double loop. I am saying this because from the code structure that loops like the only place for a leak besides having values passed under the hood of Houdini where you do not see those interactions going on. I suspect but I have not proven that \$F4 is passing the whole sequence of frames and causes an internal loop within the
opparm $rnddriver picture (“$outPath”\/“$base”.\$i.“$ext”)
And a recurvise function would then occur when the command
render $rnddriver
was called. There by rendering all the frames every loop interation. Thats my best guess at this point.
Cheers,
Nate Nesler
- tallkien
- Member
- 225 posts
- Joined: July 2005
- Offline
i=\$F4 was added after it failed with just \$Frame but I suspect something has changed since the docs were published in the way houdini interprets the stuff between opparm $rnddriver trange ( on ) f ($start $end $inc) and render $driver The hrender script has no loop at all. doesn't need one. I guess the loop may be built into the render cammand, just guessing, What John posted works without a fuss, so thanks
-
- Quick Links