[Closed] MaxScript, VRay and Rendering
Hi there everyone!
I’m working on my first MaxScript but am quite experienced in many other scripting languages so the constructs are nothing new to me. I’m hoping that someone can help me with a few problems with my script.
We are currently involved in a lot of different architectural visualisation projects and use VRay as our renderer. We pre-generate VRay Lightcaches and Irradiance Maps for all our scenes. Setting these scenes rendering is quite an arduous task sometimes taking up to one hour per camera to set rendering because we first have to set the light cache rendering then set the imap rendering with the light cache as a pre-requisite then finally set the render going with both the light cache and the imap as the pre-requisites.
What I'm attempting to do is automate this process by creating a MaxScript that prompts a user for a single output directory then changes the relevant settings and effectively renders the scene three times (once for light cache, once for imap and finally for the render itself) to an RPF stream in the selected output directory. The MaxScript will also prompt the user for a base RPS file to determine the quality settings to be used for the render.
So far I'm able to prompt the user for the destination directory, prompt the user for the render preset file, change all the relevant rendering settings in common properties and in VRay renderer properties and I am able to output the .vrlmap (light cache), .vrmap (imap) and .rpf (render) files.
Unfortunately these can only be done one at a time as it currently stands and I have only managed to achieve this in a fairly rudimentary way. I am using the render() command for the light cache and imap but if I use render() for the frames themselves it appears to ignore the render dialog box settings and doesn't output the .rpf file. This is the first of my issues, which are all inter-related and can probably all be solved by solving the major issue I have; NetRendering.
I wish to be able to farm this process off to our render farm but am not entirely sure of the process to achieve this. The MaxScript documentation on NetRender functionality is confusing and doesn't make sense to me. I would love to be able to automate it such as is loosely outlined below:
[ol]
[li]Render “vray.vrlmap” Light Cache file on a specific machine in a network render cluster with a critical priority level[/li][li]Render “vray.vrmap” Irradiance Map file on the same machine as step 1 with a dependancy on step one being complete also having a critical priority level[/li][li]Render “frame0000.rpf” final rendered output on all machines in the render cluster being dependant on steps 1 and 2 having a custom specified priority level[/li][/ol]I would like the above steps to be submitted from a single machine using a one-button approach with my script.
The main things that I wish to know are; (a) Can I get Max to act as if it just hit the render button in the render dialog box? This solution would be superb as I can already change all the properties in the render dialog and (b) How can I set up a relatively advanced net rendering system as I have outlined there that will take the render settings from the current render settings without having to parse them all through the net render commands?
Thanks in advance for any assistance on this matter, if you require any further information or clarification don't hesitate to ask.
Cheers,
Sebastian
amaizing just what i´d been looking for… hope you can succeed in doing your task…
the maxscript reference is quite extensive anyway, and vray help online also helped me quite a bit…
good luck to you.
hugs bern.
OK, so I now have everything minus the dependancies working. Unfortunately this is one of the most key requirements of my script. There is no documentation whatsoever in the MaxScript reference about setting dependancies. Anyone able to shed some light on this final issue?
here is what i don´t understand :
“renders the scene three times (once for light cache, once for imap and finally for the render itself)” why?
i´m trying to do that also but render the irradiance map first on the network and the send the final job with a dependency to the network machines…
it is quite simple actually… but i´m trying to automate it also…
oh something i remenbered…
the render setting can be pre-made and stored as a default setting somewhere in the max directyorys.
so you would end up with:
setting one: “render the imap”
setting two: “render light cache”
setting three: “render final animation”
these could be reletively simple setting pre made that you would store as a default action for all your animation.
try thinking photoshop actions maybe it will help you hugs bern:
ok so i went on this crusade for myself and i´m working on this one button soluttion…
i´ll soon post some results…
macroScript MultiCamRender
category:“Cooper”
tooltip:“Multi-camera rendering for Vray”
buttontext:“MultiCam”
(
local mycams
on isenabled return (findstring (renderers.current as string) “vray”) != undefined
on execute do
(
go_next = false
undo off
(
——VrayCam
mycams = #()
for q in cameras where ((superclassof q == camera) and (q.name != “VrayCam”)) do if not q.ishidden then append mycams q
if mycams.count > 1 then
(
animationrange = (interval 0 (mycams.count-1))
if $vraycam == undefined then
(
vraycam = freecamera name:“VrayCam”
vraycam.position.controller = linear_position()
vraycam.rotation.controller = linear_rotation()
)
else vraycam = $vraycam
with animate on
(
for c = 1 to mycams.count do
(
CamProps = getpropnames mycams[c]
for i = 1 to CamProps.count do
(
sourceprop = at time (c-1) getproperty mycams[c] CamProps[i]
try if ((sourceprop != #free) and (sourceprop != #target)) then at time (c-1) setproperty vraycam CamProps[i] sourceprop catch()
)
at time (c-1) vraycam.transform = mycams[c].transform
at time (c-1) vraycam.fov = mycams[c].fov
)
)
select $vraycam
viewport.setCamera $VrayCam
go_next = true
)
——-VrayCam
if go_next then
(
———-first stage
renderSceneDialog.close()
myrend = renderers.current
fullfilename = maxFilePath + (getFileNameFile maxfilename)
myrend.gi_on = true
myrend.gi_primary_type = 0
myrend.gi_secondary_type = 3
irmap_name = fullfilename +”.vrmap”
lightcache_name = fullfilename +”.vrlmap”
myrend.adv_irradmap_loadFileName = irmap_name
myrend.adv_irradmap_autoSave = true
myrend.adv_irradmap_autoSaveFileName = irmap_name
myrend.lightcache_loadFileName = lightcache_name
myrend.lightcache_autosave = true
myrend.lightcache_autosaveFileName = lightcache_name
myrend.options_dontRenderImage = true
myrend.adv_irradmap_mode = 4
myrend.lightcache_mode = 1
old_aa = myrend.imageSampler_type
myrend.imageSampler_type = 0
rendTimeType = 2
rendSaveFile = false
max quick render
——- first stage
——- second stage
rendSaveFile = true
myrend.adv_irradmap_mode = 2
myrend.lightcache_mode = 2
myrend.options_dontRenderImage = false
myrend.imageSampler_type = old_aa
max quick render
——- second stage
) – gonext
) — end undo
) — end on execute
)